I'm trying to use solver to solve a non-linear problem, but the results are not consistent and change under certain conditions. This problem does not exist when using Risk Solver Platform, but does when using the regular Excel Solver. The optimization and constraints are not complex, so I don't understand what is going on.
Here is the file: temp.xlsm
Notice there are macros involved with buttons attached to run the solver.
To Replicate problem:
- Open file
- Click
Months
tab - Initial Infestation should be at 11%
- Click
Optimize Net Revenue
(Correct Optimal Condition; this is fine) - Change Initial Infestation to 1%
- Click
Optimize Net Revenue
- Change Initial Infestation back to 11%
- Click
Optimize Net Revenue
Note: Optimal Net Revenue is now lower and in the last month the last column is negative when it should be zero. It seems like solver needs to be reset everytime, or there is a bug, but I can't figure it out. Here's the macro:
Sub Monthly_Solver()
Application.Run "SolverReset"
Application.Run "SolverOk", "$T$18", 1, "0", "$F$6:$F$17,$N$6:$N$17", 1, "GRG Nonlinear"
Application.Run "SolverAdd", "$F$6:$F$17", 5, "binary"
Application.Run "SolverAdd", "$N$6:$N$17", 1, "$M$6:$M$17"
Application.Run "SolverAdd", "$N$6:$N$17", 3, "0"
Application.Run "SolverAdd", "$T$18", 3, "0"
Application.Run "SolverSolve", True
End Sub
GRG Nonlinear does not guarantee finding the global optimal solution. It finds a local optimal solution and the quality of that solution is affected by the initial values you supply to the algorithm. From Frontline's website:
Right now, your
Harvest
column has 3131 inN14:N16
. If you changeinitial infestation
to 1% and solve again,N14:N17
will have the value of 3131. So your initial solution has changed. If you change it back to 11% without changing the value inN17
the solver may found another local optimal solution. If you setN17=0
you will get the same solution as the first one.On a different note, if the only reason for GRG Nonlinear is the binary
Spray
variable and the if/then conditions it represents, you can use linear constraints (so global optimality is more likely). Here's a quick reference.