- Joined
- Dec 28, 2010
- Messages
- 1
- Reaction score
- 0
I have lately been playing with the solver in Excel. It is to minimize a sum (of all deviations from a particular curve) respecting certain contraints (max and min values) while keeping a certain number (the sum of all contributing values) to a constant. My problem is now that curve optimizations seems to run well, so well, that the solver disregards the constraints. Is there any way to "force" the constraints onto the solver? I would be so glad to get some help!!
So far, this is the VBA code I have written for Excel 2007:
Sub Makro3()
Application.Run "solver.xlam!solverreset"
Application.Run "solver.xlam!solverok", "$AD$63", "2", "0", "$D$3,$D$71,$M$3,$P$3,$V$3"
Application.Run "solver.xlam!solveradd", "AH3", "2", "1"
Application.Run "solver.xlam!solveradd", "$V$3", "3", "$V$10"
Application.Run "solver.xlam!solveradd", "$V$3", "1", "$V$11"
Application.Run "solver.xlam!solveradd", "$P$3", "3", "$P$10"
Application.Run "solver.xlam!solveradd", "$P$3", "1", "$P$11"
Application.Run "solver.xlam!solveradd", "$M$3", "1", "$M$11"
Application.Run "solver.xlam!solveradd", "$M$3", "3", "$M$10"
Application.Run "solver.xlam!solveradd", "$D$3", "1", "$D$11"
Application.Run "solver.xlam!solveradd", "$D$3", "3", "$D$10"
Application.Run "solver.xlam!solveradd", "$D$71", "1", "$D$81"
Application.Run "solver.xlam!solveradd", "D$71", "3", "$D$80"
Application.Run "solver.xlam!solverok", "$AD$63", "2", "0", "$D$3,$D$71,$M$3,$P$3,$V$3"
Application.Run "solver.xlam!solversolve", True
End Sub
So far, this is the VBA code I have written for Excel 2007:
Sub Makro3()
Application.Run "solver.xlam!solverreset"
Application.Run "solver.xlam!solverok", "$AD$63", "2", "0", "$D$3,$D$71,$M$3,$P$3,$V$3"
Application.Run "solver.xlam!solveradd", "AH3", "2", "1"
Application.Run "solver.xlam!solveradd", "$V$3", "3", "$V$10"
Application.Run "solver.xlam!solveradd", "$V$3", "1", "$V$11"
Application.Run "solver.xlam!solveradd", "$P$3", "3", "$P$10"
Application.Run "solver.xlam!solveradd", "$P$3", "1", "$P$11"
Application.Run "solver.xlam!solveradd", "$M$3", "1", "$M$11"
Application.Run "solver.xlam!solveradd", "$M$3", "3", "$M$10"
Application.Run "solver.xlam!solveradd", "$D$3", "1", "$D$11"
Application.Run "solver.xlam!solveradd", "$D$3", "3", "$D$10"
Application.Run "solver.xlam!solveradd", "$D$71", "1", "$D$81"
Application.Run "solver.xlam!solveradd", "D$71", "3", "$D$80"
Application.Run "solver.xlam!solverok", "$AD$63", "2", "0", "$D$3,$D$71,$M$3,$P$3,$V$3"
Application.Run "solver.xlam!solversolve", True
End Sub