optimizationsyntax-errorcplexilog

How to get rid of : Scripting runtime error: cannot convert to a number, "[a IloNumExpr]" error


i'm still a beginner in ILOG CPLEX STUDIO.

I have some decision variable such as:

dvar int gamma [Operations][Operations]in 0..1;

to calculate some of the deductible variable, I use an "execute" block in which I want a variable to have the value of gamma[0][0] + 1:

execute{
 var a = gamma[0][0] + 1;
}

this code return me the error :

Scripting runtime error: cannot convert to a number, "[a IloNumExpr]".

I believe this has something to do with the fact that gamma is a decision variable but I don't know to get the value inside of gamma[0][0]


Solution

  • Here are 3 ways to compute e

    range Operations=0..2;
    
    dvar int gamma [Operations][Operations]in 0..1;
    
    dexpr int e1= gamma[0][0] + 1;
    
    subject to
    {
      
    }
    
    int e2= gamma[0][0] + 1;
    int e3;
    execute
    {
      e3= gamma[0][0] + 1;
    }
    
    execute
    {
      writeln(e1,e2,e3);
    }