AMPL Integer Linear Programming ORLAB Operations Research Laboratory Borzou Rostami Politecnico di Milano, Italy January 18, 2012
Integer Programming: Many linear programming problems require certain variables to have whole number, or integer, values. Such a requirement arises naturally when the variables represent entities like packages or people that cannot be fractionally divided - at least, not in a meaningful way for the situation being modeled. Integer variables also play a role in formulating equation systems that model logical conditions. Integer variables Consider the diet problem in session 2. ampl: model diet.mod; data diet.dat; ampl: solve; CPLEX 11.2.0: optimal solution; objective 3.37 1 dual simplex iterations (0 in phase I) ampl: print{j in J} (j,x[j]); Bread 4 Milk 3 Eggs 1 Meat 1.5000000000000002 Cake 0 We want the foods to be purchased in integral amounts.
By adding the keyword integer to the qualifying phrases of a var declaration, you restrict the declared variables to integer values. (var x{j in J} integer >= 0, <= q[j];) We can then try to re-solve: ampl: model diet.mod; data diet.dat; solve; CPLEX 11.2.0: optimal integer solution; objective 3.62 1 MIP simplex iterations 0 branch-and-bound nodes ampl: print {j in J} (j,x[j]); Bread 2 Milk 3 Eggs 1 Meat 2 Cake 0 Comparing this solution to the previous one, we see a few features typical of integer programming. The minimum cost has increased from 3.37 to 3.62; because integrality is an additional constraint on the values of the variables, it can only make the objective
less favorable. The amounts of the different foods in the diet have also changed. Meat that had fractional amounts in the original optimum, have increased from 1.5000000000000002 to 2. Bread has dropped from the upper limit of 4 to 2. Note: Clearly, you cannot always deduce the integer optimum by rounding the noninteger optimum to the closest integer values. Binary Variables: Set covering Problem: In the set covering problem, we are given a universe U, such that U = n, and sets,..., U. A set cover is a collection S of some of the sets from,..., whose union is the entire universe U. Formally, S is a set cover if. If be the cost associated to set e would like to select a set cover S with the minimum cost.
Suppose U= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and = {1, 2, 3, 8, 9, 10}, = {1, 2, 3, 4, 5}, = {4, 5, 7}, = {5, 6, 7}, and = {6, 7, 8, 9, 10}. Find a set cover with a minimum cost.
{ { Formulation: S.t. { }
AMPL model file (Setcovering.mod)
AMPL data file (Setcovering.dat)
Fixed Cost problem: Gandy Cloth Company is capable of manufacturing three types of clothing: Shirts, shorts, and pants. The manufacture of each type of clothing requires that Gandy have the appropriate type of machinery available. This machinery can be rented at the following rates: shirt machinery, $200/week; shorts machinery, $150/week; pants machinery, $100/week. Each type of clothing requires the amount of cloth and labor given in the table below. The sales price and variable cost are also given in the table. Labor Hours Cloth (sq. m) Sales Price Variable Cost Shirts 3 4 $12 $6 Shorts 2 3 $8 $4 Pants 6 4 $15 $8 Available: 150 hours 160 sq. m Given an integer linear programming formulation for the problem
Formulation: : The quantity of clothing of type j { { }
AMPL data file (Fixedcost.dat)
Assignment Problem: A company has 4 machines available for assignment to 4 tasks. Any machine can be assigned to any task, and each task requires processing by one machine. The time required to set up each machine for the processing of each task is given in the table below. TIME (Hours) Task1 Task2 Task3 Task4 Machine1 13 4 7 6 Machine2 1 11 5 4 Machine3 6 7 2 8 Machine4 1 3 5 9 The company wants to minimize the total setup time needed for the processing of all four tasks.
{ Formulation: S.t. { }
AMPL model file (assignment.mod)
AMPL data file (assignment.dat)
MINOS 5.5: ignoring integrality of 16 variables MINOS 5.5: optimal solution found. 8 iterations, objective 11 ampl: option solver cplex; ampl: solve; CPLEX 11.2.0: optimal integer solution; objective 11 5 MIP simplex iterations 0 branch-and-bound nodes ampl: option omit_zero_rows 1; ampl: display x; x := Machine1 Task2 1 Machine2 Task4 1 Machine3 Task3 1 Machine4 Task1 1 ;
Uncapacitated Facility Location (UFL) Given a set of potential depots and a set of clients (or customers), suppose there is a fixed cost associated with the use of depot j, and a transportation cost if all of client i s order is delivered from depot j. The problem is to decide which depots to open, and which depots serves each client so as to minimize the sum of fixed and transportation cost.
Downloading AMPL Student Edition Software http://www.ampl.com/downloads/ My Email Address rostami@elet.polimi.it Lab session web site http://home.dei.polimi.it/rostami/lab/lab5como.pdf