indexingcplexnonlinear-optimizationnon-convex

Q1 is not convex error while using decision variable in index


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?


Solution

  • 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);
    }