Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Cplex Java API: Naming decision expressions within an array of decision expressions?

ALEX FLEISCHER

ALEX FLEISCHERThu May 17, 2018 11:22 AM

  • 1.  Cplex Java API: Naming decision expressions within an array of decision expressions?

    Posted Thu May 17, 2018 07:29 AM

    Originally posted by: felx


    Hello,

    I´m currently translating an OPL model to Java.

    Within the OPL model there is an array dE of decision expressions declared like this:

     

    dexpr float dE[t in years] = decisionVariable1[t] - decisionVariable2[t]

     

    wherein years looks like this:

     

    years= [2011,2012….2020].

     

     

    Now, I would like to do the same with Java. I´m creating an Array dE of decision expressions of type IloNumExpr and fill it via a for-loop:

     

    IloNumExpr[]dE = new IloNumExpr[10];

     

    for(int i=0; i<10; i++) {

                                                                 

    dE[i] = cplex.diff(decisionVariable1[i], decisionVariable2[i]);                                    

    }

     

    Is there any way I can assign names to each element of the array dE, the same way I can assign the years [2011,2012….2020] to the array elements in OPL?

     

    Thanks,

    Felix


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Cplex Java API: Naming decision expressions within an array of decision expressions?

    Posted Thu May 17, 2018 11:22 AM

    Hi,

    have you tried

    setName

    
    
    void 
    
    
    setName(
    java.lang.String name)
    
    Sets the name of the invoking variable.

    ?

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer