Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

How to calculate the conditional sum

  • 1.  How to calculate the conditional sum

    Posted 12/24/17 10:18 PM

    Originally posted by: skyskyhuanghuang


    I have written like this:

     

    maximize

    sum(i in 1..M)

    ((i+sum(j in 1..M) j)+sum(n in 1.M) n);

     

    but  variables like j and n are conditional.(j!=i , n!=i,n!=j).How can i express it?

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to calculate the conditional sum

    Posted 01/02/18 02:26 AM

    Hi

    int M=3;

    int res=sum(i,j,n in 1..M:j!=i && n!=i && n!=j) (i+j+n);

    execute
    {
    writeln("res=",res);
    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer