Skip to content

Instantly share code, notes, and snippets.

@npow
Created July 4, 2012 04:29
Show Gist options
  • Save npow/3045339 to your computer and use it in GitHub Desktop.
Save npow/3045339 to your computer and use it in GitHub Desktop.
Sets
i activity
/
free-lunch,
mixed-nuts,
orange-juice,
heavy-ddr-session,
cheese-snacks,
cookies,
mexican-coke,
dropballers-basketball,
coding-six-hours,
riding-scooter,
rock-band,
playing-drums
/;
Parameters
c(i) calories
/ free-lunch 802
mixed-nuts 421
orange-juice 143
heavy-ddr-session -302
cheese-snacks 137
cookies 316
mexican-coke 150
dropballers-basketball -611
coding-six-hours -466
riding-scooter -42
rock-band -19
playing-drums -295
/;
Variables
do(i) do
z z;
Binary variable do(i);
Equations
objfn objective function
check constraint;
objfn.. z =e= sum((i), do(i));
check.. 0 =e= sum((i), do(i) * c(i));
Model diet /all/;
option iterlim = 999999;
option reslim = 999999;
option optcr = 0;
solve diet using mip maximizing z;
@npow
Copy link
Author

npow commented Jul 4, 2012

               S O L V E      S U M M A R Y

     MODEL   diet                OBJECTIVE  z
     TYPE    MIP                 DIRECTION  MAXIMIZE
     SOLVER  CPLEX               FROM LINE  53

**** SOLVER STATUS     1 Normal Completion         
**** MODEL STATUS      1 Optimal                   
**** OBJECTIVE VALUE                8.0000

 RESOURCE USAGE, LIMIT          0.018    999999.000
 ITERATION COUNT, LIMIT        76        999999

IBM ILOG CPLEX   Mar 17, 2012 23.8.2 DEX 31442.32372 DEG Mac x86_64/Darwin
Cplex 12.4.0.0

MIP status(101): integer optimal solution
Fixing integer variables, and solving final LP...
Fixed MIP status(1): optimal
Proven optimal solution.

MIP Solution:            8.000000    (76 iterations, 93 nodes)
Final Solve:             8.000000    (0 iterations)

Best possible:           8.000000
Absolute gap:            0.000000
Relative gap:            0.000000


                           LOWER          LEVEL          UPPER         MARGINAL

---- EQU objfn               .              .              .             1.0000      
---- EQU check               .              .              .              .          

  objfn  objective function
  check  constraint

---- VAR do  do

                              LOWER          LEVEL          UPPER         MARGINAL

free-lunch                      .             1.0000         1.0000         1.0000      
mixed-nuts                      .              .             1.0000         1.0000      
orange-juice                    .             1.0000         1.0000         1.0000      
heavy-ddr-session               .             1.0000         1.0000         1.0000      
cheese-snacks                   .             1.0000         1.0000         1.0000      
cookies                         .             1.0000         1.0000         1.0000      
mexican-coke                    .              .             1.0000         1.0000      
dropballers-basketball          .             1.0000         1.0000         1.0000      
coding-six-hours                .             1.0000         1.0000         1.0000      
riding-scooter                  .              .             1.0000         1.0000      
rock-band                       .             1.0000         1.0000         1.0000      
playing-drums                   .              .             1.0000         1.0000      
GAMS Rev 238  XXX-DEG 23.8.2 Mac x86_64/Darwin                                                                                                                                                                                         07/04/12 00:27:02 Page 7
G e n e r a l   A l g e b r a i c   M o d e l i n g   S y s t e m
Solution Report     SOLVE diet Using MIP From line 53


                           LOWER          LEVEL          UPPER         MARGINAL

---- VAR z                 -INF            8.0000        +INF             .          

  z  z


**** REPORT SUMMARY :        0     NONOPT
                             0 INFEASIBLE
                             0  UNBOUNDED


<pre>
EXECUTION TIME       =        0.001 SECONDS      2 Mb  DEX238-238 Apr  3, 2012


USER: GAMS Development Corporation, Washington, DC   G871201/0000CA-ANY
      Free Demo,  202-342-0180,  sales@gams.com,  www.gams.com   DC0000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment