OpenSolver API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Model_Creation() | |
Dim TestSheet As Worksheet | |
Set TestSheet = Sheets("test") | |
OpenSolver.ResetModel Sheet:=TestSheet | |
'Objective Definition | |
OpenSolver.SetObjectiveFunctionCell TestSheet.Cells(1, 1), Sheet:=TestSheet | |
OpenSolver.SetObjectiveSense MinimiseObjective, Sheet:=TestSheet | |
'Variables Definition | |
OpenSolver.SetDecisionVariables Union(TestSheet.Range(Cells(3, 1), Cells(3, 4)), TestSheet.Range(Cells(5, 1), Cells(5, 4))), Sheet:=TestSheet | |
'Constraints Definition | |
OpenSolver.AddConstraint TestSheet.Range(Cells(3, 1), Cells(3, 4)), RelationBIN, Sheet:=TestSheet | |
OpenSolver.AddConstraint TestSheet.Range(Cells(7, 1), Cells(7, 4)), RelationLE, TestSheet.Range(Cells(8, 1), Cells(8, 4)), Sheet:=TestSheet | |
OpenSolver.AddConstraint TestSheet.Range(Cells(10, 1), Cells(10, 4)), RelationGE, TestSheet.Range(Cells(11, 1), Cells(11, 4)), Sheet:=TestSheet | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment