My day's work...
Private Sub BtnRunModel_Click()
SolverReset
'clears solver parameters/constraints
SolverOk SetCell:="$J$16", MaxMinVal:=2, ValueOf:="0", ByChange:= _
"$F$2:$F$16,$J$2:$L$2,$K$5:$L$5"
'minimizes cost cel J16 by changing dispatch, voltage magnitude, voltage angle
SolverAdd CellRef:="$F$2:$F$16", Relation:=3, FormulaText:="$C$2:$C$16"
'constraint: dispatch levels must be >= min gen limits
SolverAdd CellRef:="$F$2:$F$16", Relation:=1, FormulaText:="$D$2:$D$16"
'constraint: dispatch levels must be <= max gen limits SolverAdd CellRef:="$J$2:$L$2", Relation:=3, FormulaText:="$J$3:$L$3" 'constraint: voltage mag must be >= min voltage limits
SolverAdd CellRef:="$J$2:$L$2", Relation:=1, FormulaText:="$J$4:$L$4"
'constraint: voltage mag must be <= max voltage limits SolverAdd CellRef:="$K$5:$L$5", Relation:=3, FormulaText:="-Pi()" 'constraint: voltage angles for bus B and C must be >= -pi
'note: voltage at bus A = 0
SolverAdd CellRef:="$K$5:$L$5", Relation:=1, FormulaText:="Pi()"
'constraint: voltage angles for bus B and C must be <= pi
SolverAdd CellRef:="$D$38:$D$43", Relation:=1, FormulaText:="$E$38:$E$43"
'constraint: apparent power flows into each bus from each line must be <= thermal line limits
SolverAdd CellRef:="$J$11:$L$11", Relation:=2, FormulaText:="$J$12:$L$12"
'constraint: real power injection balanced in each bus
SolverAdd CellRef:="$J$13:$L$13", Relation:=2, FormulaText:="$J$14:$L$14"
'constraint: reactive power injection balanced in each bus
SolverSolve UserFinish:=True
'skips user dialogue box when true
SolverFinish KeepFinal:=1, ReportArray:=Array(2)
'1 means final results kept; Array(2) returns sensitivity report
'copies shadow prices from sensitivity report and pastes into model spreadsheet
Sheets("Sensitivity Report 1").Select
Range("E43:E48").Select
Selection.Copy
Sheets("Rounds and Model").Select
Range("G21:G26").Select
ActiveSheet.Paste
Sheets("Sensitivity Report 1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete
'deletes sensitivity report when finished
End Sub
26 November 2006
I did it... all by myself...
Subscribe to:
Post Comments (Atom)
2 comments:
that's hott
That's why I do it... for the ladies...
Post a Comment