Created
May 3, 2018 14:11
-
-
Save sylvainma/66e213b7d07e77b12f4a4ccaabe1d853 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| model Baril | |
| uses "mmxprs"; !gain access to the Xpress-Optimizer solver | |
| !sample declarations section | |
| declarations | |
| ! ... | |
| Objective:linctr | |
| Items=1..3 ! Index range for items | |
| VALUE: array(Items) of real ! Value of items | |
| WEIGHT1: array(Items) of real ! Weight of items | |
| WEIGHT2: array(Items) of real ! Weight of items | |
| WTMAX1=8 ! Max weight allowed for haul | |
| WTMAX2=5 ! Max weight allowed for haul | |
| x: array(Items) of mpvar ! 1 if we take item i; 0 otherwise | |
| end-declarations | |
| ! Item: 1 2 3 | |
| VALUE :: [200, 60, 206] | |
| WEIGHT1:: [3, 1, 5] | |
| WEIGHT2:: [5, 1, 3] | |
| MaxVal:= sum(i in Items) VALUE(i)*x(i) ! Objective: maximize total value | |
| ! Weight restriction | |
| WtMax1:= sum(i in Items) WEIGHT1(i)*x(i) <= WTMAX1 | |
| ! Weight restriction | |
| WtMax2:= sum(i in Items) WEIGHT2(i)*x(i) <= WTMAX2 | |
| writeln("Begin running model") | |
| !... | |
| maximize(MaxVal) ! Solve the MIP-problem | |
| writeln("End running model") | |
| ! Print out the solution | |
| writeln("Solution:\n Objective: ", getobjval) | |
| forall(i in Items) writeln(" x(", i, "): ", x(i).sol) | |
| end-model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment