power Nonlinear constraint in cplex

Viewed 82

I'm trying to implement non-linear constraint in my cplex code:

forall (j in agent)
    pu[j] == pow(W[j],K)*pow(u[j],-K);

where pu and u are float+ decisions vectors variables, W is parameters vector and K is constant. How can I convert the constraint into a linear constraint?

Here is the rest of the code:

int N =3;

range task = 1..N; 

range agent = 1..N; 

dvar boolean x[task][agent];

dvar float+ u[agent];

dvar float+ pu[agent];

int B[agent] = [9,7,4];

int W[agent] = [2,5,4];

int V[agent] = [1,6,4];

int P[task] = [5,2,1];

int K = 3;

float UV = 10;

dexpr float z = sum(i in task, j in agent) (P[i]*(B[j]+ pu[j]) )*x[i,j];

minimize z;

subject to {
    
  forall (j in agent)
    pu[j] == pow(W[j],K)*pow(u[j],-K);
    
    
  forall (i in task)
    sum(j in agent) x[i,j]==1;
    
   forall ( j in agent)
    sum(i in task) x[i,j]==1;
    
    sum(j in agent) V[j]*u[j]<= UV;
    
}  
1 Answers

You could use CPOptimizer within CPLEX and write

using CP;

int N =3;

range task = 1..N;

range agent = 1..N;

dvar boolean x[task][agent];

int scale=100000;

dvar int+ scaleu[agent];

dexpr float u[j in agent]=scaleu[j]/scale;



int B[agent] = [9,7,4];

int W[agent] = [2,5,4];

int V[agent] = [1,6,4];

int P[task] = [5,2,1];

int K = 3;

float UV = 10;

dexpr float  pu[j in agent]=pow(W[j],K)*pow(u[j],-K);;

dexpr float z = sum(i in task, j in agent) (P[i]*(B[j]+ pu[j]) )*x[i,j];

minimize z;

subject to {

//forall (j in agent) pu[j] == pow(W[j],K)*pow(u[j],-K);

forall (i in task) sum(j in agent) x[i,j]==1;

forall ( j in agent) sum(i in task) x[i,j]==1;

sum(j in agent) V[j]*u[j]<= UV;

}

which works fine

Related