I am trying to solve the following model in CPLEX, however, I am having in trouble in the part where I want to find min or max of a set. So I have a set of completion times for order i as C[i][j] = {2,3,5} and I want to get max (C_late) which is 5 and min (C_early) which is 2. And then I wand to minimize the difference between them. I think I need to use big M method however I am not sure why its not working.

int I=...;
int J=...;
int K=...; 
int T=...;

range Order = 1..I;
range Job = 1..J;
range Machine=1..K;
range Position = 1..T;

int p[Order][Job]=...;
int a[Order][Job][Machine]=...;

dvar boolean x[Order][Job][Machine][Position];
dvar boolean z[Order][Job];
dvar int+ C_late[Order];
dvar int+ C_early[Order];
dvar int FTW[Order];
dvar int CD;
dvar int+ y [Machine][Position];
dvar int+ C[Order][Job];
dvar int Cmax;

sum(i in Order) (C_late[i] - C_early[i]);

subject to{
// Ensure that a job is scheduled on one position only
forall(i in Order, j in Job: p[i][j]>0) sum(t in Position, m in Machine) 
x[i][j][m][t] == 1;

forall(m in Machine, t in Position) sum(i in Order, j in Job: p[i][j]>0)
x[i][j][m][t] <= 1;

forall(i in Order, j in Job: p[i][j]>0 , m in Machine, t in Position)
   x[i][j][m][t] - a[i][j][m] <= 0;

forall (m in Machine)
y[m][1] >= sum(i in Order, j in Job) p[i][j]*x[i][j][m][1];

forall(m in Machine, t in Position: t>=2)
y[m][t] >= y[m][t-1] + sum(i in Order, j in Job) p[i][j]*x[i][j][m][t];

forall(i in Order, j in Job: p[i][j]>0, m in Machine, t in Position) 
C[i][j] >= y[m][t] - 100000*(1 - x[i][j][m][t]);

forall(m in Machine) 
sum(i in Order, j in Job, t in Position) p[i][j]*x[i][j][m][t] - Cmax <= 0;

**forall(i in Order, j in Job: p[i][j]>0)
C_early[i] <= C[i][j];

forall(i in Order, j in Job: p[i][j]>0)
C_late[i] >= C[i][j];**


and here is sample data set:


p= [

a = [
        [[1,1,1], [0,0,0], [0,0,0]], 
        [[0,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [0,0,0], [0,0,0]],
        [[1,0,1], [0,0,0], [0,0,0]],
        [[0,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [0,0,0], [0,0,0]],
        [[0,1,1], [0,0,0], [0,0,0]],
        [[0,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [0,0,0], [0,0,0]],
        [[1,1,1], [1,1,1], [1,0,1]],

So is it possible to minimize function like this?

asked 13 Oct '15, 17:54

HD_1's gravatar image

accept rate: 0%

Your approach to C_early and C_late is correct. What do you mean by "not working"?

(15 Oct '15, 15:35) Paul Rubin ♦♦

When I run the model, it will change the variable C[i][j] to wrong values just to minimize objective function to 0

(15 Oct '15, 18:25) HD_1
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 13 Oct '15, 17:54

Seen: 965 times

Last updated: 16 Oct '15, 13:51

OR-Exchange! Your site for questions, answers, and announcements about operations research.