0

In my model, first I calculate the number of ports in which ship drop the cargo

forall(i in 1..N,j in k+1..N)
z[i][j]==sum(z in k..N-1)z*dr[i][j][z];

Then I want to use this number as the index of "t",in the form of

t[z[i][j]] 

I'm faced with

error:5002 q1 is not convex

How I can solve this problem?

Nanhydrin
  • 4,332
  • 2
  • 38
  • 51
  • HI Hessam, welcome to Stack Overflow. I've edited your question a bit to make it more readable and hopefully get some more attention. I've included the error in the title, so people know what the real core of the question is. And I've formatted your question so the code and error message stand out and to make it more readable. There are formatting buttons along the top of the box where you type your question and it's good to use them to make it readable and to make the key information stand out. – Nanhydrin Jan 23 '19 at 09:17
  • You can't use a variable as an index in Cplex. This is only allowed when using the CP solver. – Erwin Kalvelagen Jan 23 '19 at 09:45
  • thank you all,I added "using CP" and it could solve my problem. – Hessam Soltani Jan 25 '19 at 09:55

1 Answers1

-1

How to use a decision variable as an index with CPLEX ?

range r=1..5;

float value[r]=[2,3,4.5,1,0];
dvar int i in 1..5;

maximize sum(k in r) value[k]*(k==i);
subject to
{

}

execute
{
writeln("i=",i);
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15