amplhandout - AMPL and CPLEX tutorial Gbor Pataki a August...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
AMPL and CPLEX tutorial abor Pataki August 29, 2007 1 The steel production problem 1.1 The problem 2 products can be produced at a steel mill: We can make 200 tons of product 1 in an hour; the proFt for each ton is 25 dollars; the demand is 6000 tons. We must make at least 1000 tons of this product. We can make 140 tons of product 2 in an hour; the proFt for each ton is 30 dollars; the demand is 4000 tons. We must make at least 2000 tons of this product. We have 40 hours of production time available. The goal is to design a production plan to maximize total proFt. With x i = tons of product i to be made, we get the following LP: max 25 x 1 +30 x 2 st. x 1 0 , x 2 0 1 200 x 1 + 1 140 x 2 40 1000 x 1 6000 2000 x 2 4000 (1.1) 1.2 Writing and running a correct model The simplest version of the steel problem’s solution is below: ### File: steel-simple.mod 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
var x1 >=1000, <= 6000; var x2 >=2000, <= 4000; maximize profit: 25*x1 + 30*x2; subject to time: (1/200)*x1 + (1/140)*x2 <= 40; ## here: ’profit’ and ’time’ ## are arbitrarily chosen names. --------------------------------------------------------- AMPL run (the output may look slightly different, depending on what version you are using; in particular, in the student version, that you get from ampl.com, you need to type ‘‘option solver cplex;’’, and in the version on the department’s Unix machines, you need to type ‘‘option solver cplexamp;’ ampl: model steel.mod; ampl: option solver cplex; ampl: solve; ILOG CPLEX 8.000, licensed to "university-chapel hill, nc", options: e m b q CPLEX 8.0.0: optimal solution; objective 188571.4286 0 dual simplex iterations (0 in phase I) ampl: display x1, x2; x1 = 1000 x2 = 4000 ampl: When we split the problem into model and data fles, they look like this: ### File: steel.mod param n :=2; param a {j in 1. .n}; param b; param c {j in 1. .n}; param u {j in 1. .n}; # Upper bound on production param l {j in 1. .n}; # Lower bound on production var x {j in 1. .n} <= u[j], >= l[j]; maximize profit: sum {j in 1. .n} c[j] * x[j]; 2
Background image of page 2
subject to time: sum {j in 1. .n} (1/a[j]) * x[j] <= b; ## here: ’param’ and ’var’ are reserved keywords; ’profit’ and ’time’ ## are arbitrarily chosen names. --------------------------------------------------------- ### File: steel.dat param a 1 200 2 140; param c 1 25 2 30; param u 1 6000 2 4000; param l 1 1000 2 2000; param b := 40; --------------------------------------------------------- AMPL run (the output may look slightly different, depending on
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/14/2012 for the course IE 530 taught by Professor Ravindran during the Spring '97 term at Purdue University-West Lafayette.

Page1 / 13

amplhandout - AMPL and CPLEX tutorial Gbor Pataki a August...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online