0
votes

I get this error,"CPLEX(default) cannot extract expression",but when I delete the log function in object function, the error is solved. My code is as follow :

range k=1..4;
range n=1..4;
//inputs
float p[n][k]=...;
float M=...;
float B=...;


//variables
dvar boolean w[n];
//objective



maximize  (sum(k in  k) log(sum(n in n)(w[n]*exp((-1*p[n][k]))))) ;

//constraints
subject to
{   
  sum (n in n) w[n]<= 2 ;
}

It is confusing; I do not know what the problem is. Does anyone know the solution?

2
CPLEX is limited to linear expressions, plus a few selected non-linear expressions such as quadratics. I don't think that 'log' is supported. - TimChippingtonDerrick

2 Answers

0
votes

Indeed log is not supported by CPLEX but CP can handle that. Can you add

using CP;

at the beginning of your model ? regards

0
votes

you should have different name for the loop, i.e sum(k in k) should replace the first k with another name because you already declare the second k as a range. for example: sum(l in k)