F
felicitycui
Hi All,
I tried to estimate two parameters using Excel Solver. And it is really
odd that I got a solution but the constaints are not satisfied. Here is
the VBA code:
...........
'initialize parameters
Sheets("abc").Cells(3, 11) = 0.2
Sheets("abc").Cells(4, 11) = 0.5
' next, set $k$5=$k$3+$k$4
Sheets("abc").Cells(5, 11) = Sheets("abc").Cells(3, 11) _
+ Sheets("abc").Cells(4,
11)
Sub solver_v2()
SolverReset
SolverOk SetCell:="$M$446", MaxMinVal:=1, ValueOf:="0",
ByChange:="$K$3:$K$5"
SolverAdd CellRef:="$K$3", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$K$3", Relation:=1, FormulaText:="1"
SolverAdd CellRef:="$K$4", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$K$4", Relation:=1, FormulaText:="1"
SolverAdd CellRef:="$k$5", Relation:=1, FormulaText:="1"
SolverOk SetCell:="$M$446", MaxMinVal:=1, ValueOf:="0",
ByChange:="$K$3:$K$5"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
End Sub
The final estimate for $k$5 is beyond 1. Can anybody help me with that?
Thanks a lot!
Lily
I tried to estimate two parameters using Excel Solver. And it is really
odd that I got a solution but the constaints are not satisfied. Here is
the VBA code:
...........
'initialize parameters
Sheets("abc").Cells(3, 11) = 0.2
Sheets("abc").Cells(4, 11) = 0.5
' next, set $k$5=$k$3+$k$4
Sheets("abc").Cells(5, 11) = Sheets("abc").Cells(3, 11) _
+ Sheets("abc").Cells(4,
11)
Sub solver_v2()
SolverReset
SolverOk SetCell:="$M$446", MaxMinVal:=1, ValueOf:="0",
ByChange:="$K$3:$K$5"
SolverAdd CellRef:="$K$3", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$K$3", Relation:=1, FormulaText:="1"
SolverAdd CellRef:="$K$4", Relation:=3, FormulaText:="0"
SolverAdd CellRef:="$K$4", Relation:=1, FormulaText:="1"
SolverAdd CellRef:="$k$5", Relation:=1, FormulaText:="1"
SolverOk SetCell:="$M$446", MaxMinVal:=1, ValueOf:="0",
ByChange:="$K$3:$K$5"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
End Sub
The final estimate for $k$5 is beyond 1. Can anybody help me with that?
Thanks a lot!
Lily