# Operator error in operating cost model constraint

I have built a model to minimize the operating cost and when I coded a model in CPLEX, it gave an error at Cons09: Function operator/(int,dvar int+) not available in context CPLEX. I think maybe the problem lies in my model design as it is a big model. Here are my parameters:

int Numtask =...;
int Numresource =...;

range Task = 1..Numtask;
range Resource = 1..Numresource;

// parameters

int h[Task]=...;// Manhour of task j
int a[Resource][Task]=...; // license of engineer t
int C[Resource]=...;// cost of engineer t
int A[Task]=...;// nightstop time of t
float B=0.15;
int M=9000;


Here are my decision variables:

dvar float+ g[Resource];
dvar boolean x[Resource][Task];
dvar int+ m[Task];
dvar float+ b[Resource][Task];
dvar float+ n[Resource][Task];
dvar float+ nmax[Resource];
dvar float+ bmin[Resource];
dvar int+ man[Task];

dexpr float cost =sum(t in Resource) C[t]*g[t];

minimize (cost);


My constraints are as follows:

  subject to{
//cons01:
forall(j in Task, t in Resource)
x[t][j]==a[t][j];

//cons02:
forall(j in Task)
sum(t in Resource) x[t][j]==1;

//cons03:
forall(t in Resource)
sum(j in Task) x[t][j]==1;

//cons04:
forall(j in Task)
sum(t in Resource) x[t][j]*a[t][j]<=2;

//subcons04:
forall(j in Task){
man[j]==sum(t in Resource) x[t][j]*a[t][j];
}

//cons05:
sum(t in Resource, j in Task) x[t][j]==Numtask;

//cons06:
forall(t in Resource){
g[t]>=(1+B)*sum(t in Resource, j in Task)x[t][j]*a[t][j];
}

//cons07:
forall(j in Task){
m[j]>=A[j]&&m[j]<=A[j]+30;
}

//cons08:
forall(t in Resource, j in Task){
b[t][j]==M*(1-x[t][j])+m[j];
}

//cons09:
forall(t in Resource, j in Task){
n[t][j] == b[t][j]+h[j]/man[j];
}

//cons10:
forall(t in Resource, j in Task){
n[t][j]<=1770;
}

//cons11:
forall(t in Resource){
nmax[t]-bmin[t]<=720;
}
//subcons11:
forall(t in Resource, j in Task){
nmax[t]>=n[t][j];
}
//subcons11:
forall(t in Resource, j in Task){
bmin[t]<=b[t][j];
}
//cons12:
forall(t in Resource){
720-sum(j in Task)x[t][j]*(n[t][j]-b[t][j])>=30 && 720-sum(j in Task)x[t][j]*(n[t][j]-b[t][j])<=40;
}

}


How can I fix this?

• please give a more descriptive title to your question, that way other's who run into the same problem can benefit from the answers as well. Commented Sep 23, 2021 at 18:11

## 1 Answer

Integer programming models solved by CPLEX (or most other solvers) require linear or, in certain very limited cases, quadratic constraints. Your constraint 9 involves dividing a parameter (h) by an integer variable (man), which results in a nonlinear expression. Multiplying both sides by man will not help, since that produces an equation with products of variables, which is not among the limited cases where quadratic constraints are allowed.

Assuming that man[j] can never be 0 and has an upper bound of M, you can add binary variables z[j][i] (j in Task, i in 1...M), where z[j][i] = 1 means man[j] = i. Add the constraint that z[j][1] + ... + z[j][M] = 1, and the constraint that man[j] = z[j][1] + 2*z[j][2] + ... + M*z[j][M]. The term h[j]/man[j] in constraint 9 can now be replaced with h[j]*(z[j][1] + 1/2*z[j][2] + ... + 1/M*z[j][M]).