Professional Documents
Culture Documents
to CPLEX OPL
Operations Research Lab
Department of Industrial and
Systems Engineering
Course content
• CPLEX installation
• CPLEX introduction with examples
• Product mix problem
• Budget allocation problem
• Knapsack problem
• Assignment problem
• N queen problem
• Travelling salesman problem
CPLEX
Installation
Operations Research Lab
Department of Industrial and
Systems Engineering
Fill all the require credential
Institute Mail Id
After verification code select create account
Select any cos installer
After download installation
Run as administrator
Check space
requirement
Types of Programming
Representing a problem
OPL separates the model and its instance
In the OPL IDE, a model and data file are associated in a run configuration.
OPL has two main kinds of data: constants and decision variables.
Results
Debug
© K N Reddy Email: knreddy@iitkgp.ac.in
Objective function
m
Maximize z = c x i i
i1
a x bj
i, j i for j = 1, …, n
i1
xi 0
Non negativity
for i = 1, …, m
Constraint
subject to {
Constraint_1:
2*x1+2*x2+x3 <= 400;
Constraints
Constraint_2:
3*x1+x2+x3 <= 450;
Constraint_3:
x1+4*x2 <= 390;
}
execute PARAMS {
cplex.tilim = 10;
}
xi 0 i
1..n
Non negativity
Constraint
Where
m = 3; // No. of Variables
n = 3; // No. of Constraints
c = [30, 55, 23]; // Objective Coefficients
A = [[2, 2, 1], [3, 1, 1], [1, 4, 0]]; // Constraint
Coefficients
b = [400, 450, 390]; // RHS
x1 2x2 12
2x1 3x2 = 12
≥8
2x1 x2
Non negativity
x1 0, x2 0 Constraint
Constraint_2:
sum(i in vars) (A[2][i]*x[i]) == b[2];
Constraint_3:
sum(i in vars) (A[3][i]*x[i]) >= b[3];
}
m = 2; // No. of Variables
n = 3; // No. of Constraints
c = [3, 2]; // Objective Coefficients
A = [[1, 2], [2, 3], [2, 1]]; // Constraint
Coefficients
b = [12, 12, 8]; // RHS
Statistics
Objective Function:
Constraint 1 :
Sales Volume of A is 80% of total sales
X1 >= 0.8 * (X1 + X2)
Constraint 2 :
Cannot sell more than 110 units of A
X1 <= 110
Constraint 3:
Raw material availability
(2 * X1 + 3 * X2) <= 300
Non-negativity constraints:
X1, X2 >= 0
Q2. Alumco manufactures aluminum sheets and aluminum bars.
The maximum production capacity is estimated at either 800
sheets or 600 bars per day. The maximum daily demand is 550
sheets and 560 bars. The profit per ton is $40 per sheet and $35
per bar. Determine the optimal daily production mix.
X1 = No of sheets manufactured per day
X2 = No of bars manufactured per day
Objective Function:
Maximize Profit (Z) = 40 * X1 + 35 * X2
Constraints:
Production Capacity constraint
X1 / 800 + X2 / 600 <= 1
Non-negativity constraints
X1, X2 >= 0
DONE