0% found this document useful (0 votes)
71 views

IE 322 Lab 3 Compact Form Using Data

The document describes modeling a linear programming problem in CPLEX to optimize student course selections given preferences and capacity constraints. It includes: 1. Defining the parameters of the problem - number of students/courses, preference scores, course capacities. 2. Defining decision variables as binary variables indicating if a student takes a course. 3. Defining the objective function to maximize total preference score based on course selections. 4. Defining constraints - each student selects the required number of courses, number of students in each course is below capacity.

Uploaded by

Ony Ouss
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

IE 322 Lab 3 Compact Form Using Data

The document describes modeling a linear programming problem in CPLEX to optimize student course selections given preferences and capacity constraints. It includes: 1. Defining the parameters of the problem - number of students/courses, preference scores, course capacities. 2. Defining decision variables as binary variables indicating if a student takes a course. 3. Defining the objective function to maximize total preference score based on course selections. 4. Defining constraints - each student selects the required number of courses, number of students in each course is below capacity.

Uploaded by

Ony Ouss
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

IE 322 - Industrial

Operations Analysis II -
Lab
Compact Form

u Modeling Linear Programs needs 5 steps :


1. Define the parameters of the problem
2. Define decision Variables
3. Define the objective function
4. Define the constraints.
5. explain the meaning of each constraint.
Define the parameters of the problem

Cplex Stands for Example


code
int Integer number {0, 1,2, …} int N=10;
float Continuous number {0.01, float S= 3.5;
1.23, …
boolean Zero-one number { 0 or 1} boolean M=1;
Define decision Variables

Cplex code Stands for Example


dvar int+ Positive Integer dvar int+ x;
number {0, 1,2, …}
dvar float+ Positive Continuous dvar float+ y;
number {0.01, 1.23, …
dvar boolean Zero-one number { 0 dvar boolean s;
or 1}
Define decision Variables

u To define a decision variables in Cplex:


1. Write dvar for each decision variable. Ex. If we have two integer decision
variables
u dvar int+ x1;
u dvar int+x2;
2. Define an integer equal the total number of decision variable, make a range
from 1 to total number of variables, and finally define a decision variable of the
range. Ex.
1. int N=2;
2. range R= 1..N;
3. dvar int+ x[R];
3. If we have a decision variable with two indices, we make two ranges as we will
see in the next example.
Reading data in the same project

u To read data from “projectName.dat”


u Simply write: parameter name = …;
u Ex.:
u int N=…;
Then go to “projectName.dat” and write a value for N:
N= 10;
u int cap[course]=…;
u In “projectName.dat” write the name of array or matrix without brackets:
u cap=[6 8 5 5 6 5];
Example

u (Graves and Associates, 1993) Ulern University uses a mathematical


model that optimizes student preferences taking into account the
limitation of classroom and faculty resources. To demonstrate the
application of the model, consider the simplified case of 10
students who are required to select two courses out of six offered
electives. The table below gives scores that represent each
student’s preference for individual courses, with a score of 100
being the highest. For simplicity, it is assumed that the preference
score for a two-course selection is the sum of the individual score.
Course capacity is the maximum number of students allowed to
take the class.
Example
Preference score for course
Student 1 2 3 4 5 6
1 20 40 50 30 90 100
2 90 100 80 70 10 40
3 25 40 30 80 95 90
4 80 50 60 80 30 40
5 75 60 90 100 50 40
6 60 40 90 10 80 80
1 45 40 70 60 55 60
8 30 100 40 70 90 55
9 80 60 100 70 65 80
10 40 60 80 100 90 10
Course
6 8 5 5 6 5
capacity

Formulate the problem as an ILP and find the optimum solution.


Solution (filename.mod)

u Parameters
//Parameters
int N=...;
int M=...;
range student=1..N;
range course=1..M;
int cap[course]=...;
int P[student][course]=...;
u Decision Variables
//Decision Variables
dvar boolean x[student][course];
Solution (filename.dat)
N=10;
M=6;
TotCoursesPerStudent=2;
cap=[6 8 5 5 6 5];
P=[
[20 40 50 30 90 100]
[90 100 80 70 10 40]
[25 40 30 80 95 90]
[80 50 60 80 30 40]
[75 60 90 100 50 40]
[60 40 90 10 80 80]
[45 40 70 60 55 60]
[30 100 40 70 90 55]
[80 60 100 70 65 80]
[40 60 80 100 90 10]
];
Objective Function

//Objective function
dexpr float z= sum(i in student, j in course) P[i][j]*x[i][j];

maximize z;
Constraints

//Constraints
subject to{
forall(i in student)
sum(j in course)x[i][j]==TotCoursesPerStudent;

forall(j in course)
sum(i in student)x[i][j]<=cap[j];
{
Run Configuration

1
2
Solution
To be cont.

You might also like