Unit 8

Non-linear Optimisation and Portfolio Selection

Nonlinear Optimization and Portfolio Selection · Data, Models, and AI-Empowered Decision Making
8.1 Linear versus Non-linear 8.2 Curve Fitting and Trendlines 8.3 Wyndor Marketing Costs 8.4 Portfolios and the Efficient Frontier 8.5 Separable Programming and Evolutionary Algorithms 8.6 Course Project 8.7 Summary and Assignment 5 interactive demonstrations · 5 classroom exercises
How to use this e-textbook. Orange panels are interactive demonstrations where changing parameters, moving sliders or changing starting points recalculates curves, optima and risk-return charts immediately. Green panels are classroom exercises; complete them and select “Check” for feedback and reference values. This unit has four models:a fifth-degree polynomial (the multi-start trap),Wyndor with marketing costs,a three-stock portfolio,overtime and separable programming.

8.1 Non-linear Programming: Why It Is Harder Than Linear Programming

Linear programming relies on a key proportionality assumption: the contribution of each activity is proportional to its level, so the objective always takes the form “coefficient × decision variable.” When this assumption fails, the problem becomes a non-linear programme.

Linear versus Non-linear

ComparisonLinear programmingNon-linear programming
Activity contributionproportional to activity levelnon-proportional (for example, diminishing marginal returns)
Modelling difficultywrite coefficients and variables directlyspecify the functional form first, often via curve fitting
Solution difficultymature algorithms such as simplex guarantee a global optimumthe solver may stop at a local optimum or even fail
Location of optimumalways at a corner of the feasible regioninterior, boundary or one of several local optima

Four Types of Non-proportional Relationships

Diminishing marginal returns (common in advertising and marketing) Piecewise-linear change (overtime cost is an example) Increasing marginal returns (economies of scale and learning curves) Discontinuous diminishing returns (quantity discounts and setup costs)
Recognising the shape of the curve is the first step in choosing a functional form.
Three challenges of non-linear programming:① building the model is more complex because the functional form must be chosen first;② solving is much harder and may fail;③ different starting values may produce different “optima”—the trap repeatedly emphasised in this unit.

8.2 Curve Fitting and Multi-Start Solving

How to Obtain a Non-linear Relationship

  1. Plot the data as a scatter chart.
  2. Add a trendline (Chart Tools → Layout → Trendline).
  3. Choose a functional form (linear, logarithmic, polynomial, power or exponential), inspect R² and residuals, and check whether the parameters have economic meaning.
Interactive Demonstration 1

Linear or Quadratic? Let the Data Decide

The table gives net profit per door as output varies, using this unit’s Wyndor marketing-cost model. Switch functional forms and compare fitted curves and R²—this mimics the Trendline dialog.

Linear-fit R²
Quadratic-fit R²
Quadratic coefficient
Optimal output

Multi-Start Search: The Same Model, Different “Optima”

Consider Maximise Profit = 0.5x⁵ − 6x⁴ + 24.5x³ − 39x² + 20x subject to 0 ≤ x ≤ 5. It has two local maxima, so a solver starting from different values can stop in different places.

Interactive Demonstration 2

Change the Starting Value and the Result Changes

Select three starting values (0, 3 and 4.7) and see where the solver stops. Local maxima and the global optimum are marked.

Starting value
Converged x
Profit at that point
Global optimum?

Classroom Exercise 1

Where Does Each Starting Value Converge?

The model has two local maxima on 0 ≤ x ≤ 5 (approximately x = 0.37 and x = 3.12). Determine where searches from the three starting values stop.

8.3 Two Non-linear Cases

Case 1: Wyndor with Marketing Costs

Market research shows that, without advertising, Wyndor can sell only a small fraction of output; selling everything requires substantial advertising. Curve fitting estimates weekly marketing cost for production rates D and W as: doors 25D²; windows (200/3)W²; gross margin is about USD 375 per door and USD 700 per window. Therefore:

Net profit from doors = 375D − 25D²; net profit from windows = 700W − (200/3)W²
Maximise Profit = 375D − 25D² + 700W − (200/3)W²
Constraints: D ≤ 4; 2W ≤ 12; 3D + 2W ≤ 18; D ≥ 0, W ≥ 0
Interactive Demonstration 3

Profit Curve with Marketing Costs

Drag D and W to see net profit. The curve shows net profit while moving along Plant 3’s constraint 3D + 2W = 18; the red point is your current choice and the green point is the grid-search optimum.

Current net profit
Feasible?
Optimal solution
Maximum net profit

Classroom Exercise 2

Optimal Output with Marketing Costs

Solve the model above and enter optimal door output, window output and maximum net profit (3% tolerance).

Case 2: Portfolio Selection

Large fund managers commonly use non-linear-programming models to set portfolio weights. Investors care about expected return and risk—a cost-benefit trade-off (non-linear) model:minimise risk subject to expected return meeting a required level.

StockExpected returnRisk (standard deviation)Stock pairCross risk (covariance)
121%25%1 and 20.040
230%45%1 and 3−0.005
38%5%2 and 3−0.010
Decision variables: S₁, S₂ and S₃ are the portfolio weights
Minimise Risk = (0.25S₁)² + (0.45S₂)² + (0.05S₃)² + 2(0.04)S₁S₂ + 2(−0.005)S₁S₃ + 2(−0.01)S₂S₃
Constraints: 0.21S₁ + 0.30S₂ + 0.08S₃ ≥ 0.18; S₁ + S₂ + S₃ = 100%; Sᵢ ≥ 0
Interactive Demonstration 4

Risk and Return: Build Your Own Portfolio

Drag the first two weights (the third adjusts automatically) and see where your portfolio lies on the risk-return map. Light points are more than 10,000 feasible portfolios, the green curve is the efficient frontier (minimum risk for each return), and the red star is this problem’s optimum.

Weight on stock 3
Expected return
Portfolio risk (standard deviation)
Meets the 18% requirement?
Optimal portfolio for this problem
Minimum risk
Expected return of the optimal portfolio

Classroom Exercise 3

Minimum-Risk Portfolio

With expected return at least 18%, enter minimum-risk weights and risk (standard deviation; 5% tolerance).

8.4 Separable Programming and Evolutionary Algorithms

Case: Wyndor with Overtime

Wyndor receives an order for a special handmade product that will occupy Plant 1 and Plant 2 capacity for the next four months. Remaining workers must work overtime to produce standard products. Overtime adds cost, so profit is lower at the same output—a piecewise-linear non-proportional relationship.

ProductMaximum regular-time outputMaximum overtime outputTotalRegular-time unit profitOvertime unit profit
Doors314$300$200
Windows336$500$100
Let DR and DO be doors produced in regular time and overtime; WR and WO are analogous
Maximise Profit = 300DR + 200DO + 500WR + 100WO
Constraints: DR ≤ 3; WR ≤ 3; (DR+DO) ≤ 4; (WR+WO) ≤ 6; 3(DR+DO) + 2(WR+WO) ≤ 18
Interactive Demonstration 5

Separable Programming: Break a Curve into Linear Segments

Four sliders represent regular-time and overtime output for two products. Regular-time capacity is limited to 3 each, and additional output must be overtime at lower unit profit.

Total door output D
Total window output W
Plant 3 hours
Total profit

Classroom Exercise 4

Optimal Schedule with Overtime

Enter the four output quantities and total profit under the optimal plan.

Why Use Separable Programming?

  • Transform the problem into Linear programming, enabling a fast solution.
  • A linear programme can generate a sensitivity report(shadow prices and allowable ranges)—non-linear solvers usually cannot.
  • The method segments each activity that violates proportionality, creates one variable per segment, and uses segment slope as unit profit.

Evolutionary Solver and Genetic Algorithms

Evolutionary Solver follows a completely different logic. A standard solver starts from a single solution and searches in improving directions. Evolutionary Solver generates an entire population of solutions and iterates through “pairing → offspring → mutation → survival of the fittest” until several generations show no improvement. It suits rough, irregular models with many local optima.

Evolutionary Algorithms: Logic and Characteristics

The method borrows a biological metaphor: each candidate solution is an individual’s “chromosome,” with its decision values encoded as “genes”;a group of candidate solutions is the population, and the objective value measures each individual’s “fitness.” Each generation does three things:

  • Selection: fitter individuals are more likely to reproduce—survival of the fittest.
  • Crossover: combine genes from two parents to create offspring. For portfolios, this means exchanging and blending two sets of weights.
  • Mutation: randomly change a few genes (for example, increase or decrease a weight slightly). This is crucial for shaking a population out of a local optimum.
Initialise the population randomly create a set of solutions Evaluate fitness objective value Selection Crossover Mutation New generation average fitness may improve Repeat until consecutive generations show no improvement
Evolutionary loop: initialise → evaluate fitness → select, crossover and mutate → new generation, repeated until convergence.

Its characteristics determine when it is suitable:

  • No gradient required: it only needs to calculate the objective for a set of values, so it handles rough, discontinuous, conditional or integer models—the cases ordinary solvers find hardest.
  • Starts from a population rather than one point, reducing the chance of immediate entrapment in a local optimum, but it does not guarantee a global optimum—only a sufficiently good solution.
  • Results are random: two runs on the same model may differ. Fix a random seed and compare multiple runs rather than relying on one.
  • Parameters must be set: population size, crossover rate, mutation rate, generations and convergence criteria all affect quality and runtime.
  • Computationally intensive: the objective is evaluated thousands of times. It is best for problems with relatively few variables but difficult model structure.
  • Strong on combinatorial problems: selecting a subset from many candidates (stocks, sites), scheduling with logical constraints and multi-modal curve fitting.

Case: Selecting a Portfolio That Beats the Market

A common objective for investment managers is to beat the market. If past performance has some predictive value, it makes sense to search for portfolios that beat the market most often. In this case, seven A-share stocks (ICBC, PetroChina, Kweichow Moutai, BYD, COSCO Shipping Holdings, China Vanke and Ping An) have returns for the past 12 quarters, along with the SSE A-Share Index over the same period; assign a weight to each stock.

ElementContent
Decision variablesweights for seven stocks w₁ … w₇, with 0 ≤ wᵢ ≤ 1 and Σwᵢ = 1
ObjectiveMaximise the number of quarters in which the portfolio return exceeds the index (out of 12)
Datareturns for seven stocks over 12 quarters; contemporaneous SSE A-Share Index returns

The objective is unusual: it counts wins, not the size of wins. A small change in weights may leave the win count unchanged or jump it by one—the objective is a step function, non-differentiable and discontinuous, with many tied solutions. Ordinary solvers struggle; evolutionary algorithms are appropriate:the population is a set of weight combinations,fitness is the number of winning quarters (plus a small penalty enforcing weights summing to one),Crossover blends two weight vectors, and Mutation randomly changes a few weights slightly.

A simple comparison with this data:the equal-weight portfolio(1/7 in each stock) beat the index in 8 of the past 12 quarters. Blindly generating 200,000 random weight vectors, most beat the index only 6–8 times; only a few dozen reached 11 wins, and only an extremely small number reached 12.This is why we use search rather than luck: evolutionary algorithms accumulate information from each trial and move toward higher fitness over generations.

Two cautions.First, the objective itself invites data mining: selecting portfolios by past win counts easily confuses historical coincidence with a pattern (the “history does not represent the future” failure in Section 8.5). A more robust approach examines return, volatility and maximum drawdown together, and runs scenario analysis.Second, an evolutionary algorithm returns only a sufficiently good solution, not a mathematical optimum; changing the random seed or parameters may change the result, so report the settings and run counts.

8.5 AI and the Course Project

AI activity

Curve fitting and multi-start search
① Give AI activity and profit data and ask for a fitted function.
② Ask why that functional form was selected and what the parameters mean economically.
③ Multi-start search: ask for three different initial solutions and compare results.
④ Verification: enter the function in Excel and use Solver to verify the optimum.
⑤ Record the difference between AI’s fit and Excel’s trendline.

When AI Portfolio Recommendations Fail

Failure conditionWhy it failsHow to guard against it
History does not represent the futureusing past returns to estimate future returnsrun scenario analysis; do not rely blindly on backtests
Correlations changeassets move together in crisesstress-test high-correlation scenarios
Optimising only the meanignoring volatility and tail riskinspect standard deviation, maximum drawdown and percentiles
Constraints ignoredAI does not know your investment limitsstate constraints clearly and verify each one
Recommendation not implementableodd lots, taxes and liquidity problemscalculate implementation costs before deciding
Classroom Exercise 5

Where Will an AI Recommendation Fail?

Evaluate the following four statements.

Course Project Requirements (1): Objective and Deliverables

  • Objective: choose a real management problem and complete the full “data — model — AI collaboration — recommendation” process.
  • Deliverable: a written report; no classroom presentation.
  • Report elements: problem definition, data description, model and method, interpretation and recommendation.
  • Required AI-use statement: which tool, for what purpose and how it was verified.
  • Topic guidance: extend a course case or address a real problem from your workplace.

Course Project Requirements (2): Report Outline

  1. Problem and context: what decision is needed and how will it be measured?
  2. Data and definitions: sources, field meanings and cleaning.
  3. Model and solution: why this model, and how it is solved.
  4. Results and interpretation: what the result is and what it means for management.
  5. AI collaboration and verification: what AI did and what problems you found.
  6. Recommendation and limitations: what to do, plus boundaries and risks.

8.6 Summary and Course Review

  • Non-linearity arises from non-proportional relationships; such models are much harder to solve and offer no guarantee of finding a global optimum.
  • Curve fitting and multi-start search are standard tools: different starting values can yield different “optima.”
  • Separable programming converts piecewise-linear problems into linear programmes and provides sensitivity reports.
  • Evolutionary or genetic algorithms suit rough, irregular models.

The Course Spine across Eight Units

UnitCore questionTypical tools
1 Data and descriptive statisticsWhat do the data look like?Descriptive statistics, histograms, box plots, AI fundamentals
2 Probability and hypothesis testingIs this difference real?Normal distribution, confidence intervals, four-step testing, A/B tests
3 RegressionWhat influences the outcome?Four-step regression, R², significance, dummy variables, log models
4 Time series and textWhat will happen next?Seasonal factors, smoothing, causal forecasting, LLM labelling
5 Linear programmingHow should resources be allocated?Four-step modelling, graphical solution, Solver, sensitivity analysis
6 Modelling and integer programmingWhether, and how many?Modelling standards, integer and binary variables, scheduling, setup costs
7 Uncertainty and simulationHow large is the risk?Decision criteria, decision trees, Bayesian updating, Monte Carlo
8 Non-linear optimisation and portfoliosWhat if relationships are non-proportional?Curve fitting, multi-start search, separable programming, portfolio optimisation
Course project. Prepare a report following Section 8.5: problem—data—model—results—AI collaboration—recommendation and limitations. Include an AI-use statement and explain how you verified AI output.

Appendix: Interactive Demonstrations and Classroom Exercises

LocationTypeContent
8.2DemonstrationLinear versus quadratic fit (trendlines)
8.2DemonstrationMulti-start search: three starting values
8.3DemonstrationWyndor profit curve with marketing costs
8.3DemonstrationPortfolio risk-return map and efficient frontier
8.4DemonstrationSeparable programming: regular and overtime output
8.2ExerciseWhere Does Each Starting Value Converge?
8.3ExerciseOptimal Output with Marketing Costs
8.3ExerciseMinimum-Risk Portfolio
8.4ExerciseOptimal Schedule with Overtime
8.5ExerciseWhere Will an AI Recommendation Fail?

Data sources: 单元8_非线性与组合练习.xlsx and model parameters from WyndorExtension.xlsx and Portfolio.xlsx. Every optimum is calculated on the page by grid search or enumeration and can be checked against Excel Solver.

Unit Glossary (English–Chinese)

English中文
Non-linear programming非线性规划
Curve fitting曲线拟合
Local optimum局部最优
Global optimum全局最优
Separable programming可分离规划
Evolutionary algorithm演化算法
Portfolio投资组合
Efficient frontier有效前沿
Covariance协方差