Originally posted by: Allexandre
Hi,
I'm implementing a linear programming where my objective function is:
My code is:
IloExpr spfo(env);
for (int i = 0; i <= d.n; i++){
if (i != 0) {
spfo -= sp.pi_[(i-1)] * sp.y[i-1];
sprintf(name,"y[%d]",i);
sp.y[i-1].setName(name);
}
for (int j = 1; j <= (d.n+1); j++){
if(i != j){
if (!((i == 0) && (j == d.n+1))){
spfo += d.c[i][j] * sp.x[(d.n+1)*(i) + (j-1)];
sprintf(name,"x[%d][%d]",i,j);
sp.x[(d.n+1)*(i) + (j-1)].setName(name);
sprintf(name,"f[%d][%d]",i,j);
sp.f[(d.n+1)*(i) + (j-1)].setName(name);
}
}
}
}
//int L = CPXXgetnumrows(cpx.envmp, cpx.lpmp) - (d.n + 1);
for (int l = d.n+1; l <= (d.n + 1 + d.n); l++){
sp.beta_[l-(d.n + 1)] = pi[l];
IloExpr spfoaux(env);
for (int i = 1; i <= d.n; i++) spfoaux += sp.ul_[i-1]*sp.y[i-1];
spfo -= sp.beta_[l-(d.n + 1)]*floor(double(spfoaux));
}
spfo -= sp.pi0_; // -pi_0
sp.fo = IloAdd(sp.mod, IloMinimize(env, spfo));
spfo.end();
My variables are: sp.x, sp.y and sp.f
sp.beta_, sp.pi_ and sp.pi0_ are parameters whose stores the values from the constraints of my master problem.
sp.ul_ also are a parameter.
d stores some data about my problem, like the number of nodes, demands, etc.
but it returns an error saying that it cannot convert IloExpr or IloVar (if I put the floor in my variable y_i) in double.
There is any way to do this (apply floor in my objetctive function)?
#CPLEXOptimizers#DecisionOptimization