Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to solve this set problem?

    Posted 12/15/11 08:10 AM

    Originally posted by: deepalcoholic


    .mod file
    int n = 10;
    range s = 1..n;
    int a[s] = 0,10,20,30,40,0,60,70,80,90;

    {int} b = {w|w in s:a[w]^2 <= 10000};

    execute
    {
    writeln(b);
    }

    When I run the mode file above, the b set I get is empty?
    But when I replace {int} b = {w|w in s:a[w]^2 <= 10000}; by
    {int} b = {w|w in s:a[w]^2 >= 100}; the "b" set I get is not empty.
    I need help to solve the above problem?
    Thank you!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to solve this set problem?

    Posted 12/15/11 03:05 PM
    Hi

    for b I get

    {1 2 3 4 5 6 7 8 9 10}
    


    Which version do you use?

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: How to solve this set problem?

    Posted 12/16/11 02:04 AM

    Originally posted by: deepalcoholic


    i use 12.3 academic
    what version do u use?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: How to solve this set problem?

    Posted 12/16/11 03:08 AM
    Hi

    I also use CPLEX 12.3
    Can you attach a screenshot?
    We should have the same results.

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: How to solve this set problem?

    Posted 12/16/11 03:43 AM

    Originally posted by: deepalcoholic


    hi,this is my test
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: How to solve this set problem?

    Posted 12/16/11 03:44 AM

    Originally posted by: deepalcoholic


    Hi,this is my result
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: How to solve this set problem?

    Posted 12/16/11 04:21 AM

    Originally posted by: SystemAdmin


    Hi,

    the code
    int n = 10;
    range s = 1..n;
    int a[s] = [0,10,20,30,40,0,60,70,80,90];
     
    {int} b = {w|w in s:a[w]^2 <= 10000};
    {int} c = {w|w in s:a[w]*a[w] <= 10000};
     
    execute
    {
    writeln("b=",b);
    writeln("c=",c);
    }
    

    results in
    b= {}
    c= {1 2 3 4 5 6 7 8 9 10}
    


    As far as I remember the operator '^2' does not correspond
    to the expected 'squared' operator, but to some bit-operation
    ('exclusive or').

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: How to solve this set problem?

    Posted 12/16/11 04:21 AM

    Originally posted by: SystemAdmin


    Hi,

    the code
    int n = 10;
    range s = 1..n;
    int a[s] = [0,10,20,30,40,0,60,70,80,90];
     
    {int} b = {w|w in s:a[w]^2 <= 10000};
    {int} c = {w|w in s:a[w]*a[w] <= 10000};
     
    execute
    {
    writeln("b=",b);
    writeln("c=",c);
    }
    

    results in
    b= {}
    c= {1 2 3 4 5 6 7 8 9 10}
    


    As far as I remember the operator '^2' does not correspond
    to the expected 'squared' operator, but to some bit-operation
    ('exclusive or').

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: How to solve this set problem?

    Posted 12/16/11 04:34 AM

    Originally posted by: deepalcoholic


    Thank you for your answer.

    but AlexFleischer said he can get the result using ^,I don't know why?

    not just ^,but also the function pow() and sqrt() doesn't work either
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: How to solve this set problem?

    Posted 12/16/11 04:48 AM

    Originally posted by: SystemAdmin


    The behaviour of '^2' is somewhat expected from the javascript definition.

    But I agree - the behaviour of pow() is strange ...
    {int} d = {w|w in s: pow(a[w],2) <= 10000};
    float x = pow(a[2],2);
     
    execute
    {
      writeln("x = ", x);
      writeln("d=",d);
    }
    


    results in
    x = 100
    d= {}
    


    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: How to solve this set problem?

    Posted 12/16/11 05:08 AM

    Originally posted by: SystemAdmin


    It must be a problem with the evaluation of the condition for which the set is constructed, as the following code works:
    float powa[w in s] = pow(a[w],2);
    {int} e = {w|w in s: powa[w] <= 10000.0};
    execute
    {
      writeln("powa = ", powa);
      writeln("e=",e);
    }
    

    results in
    powa =  [0 100 400 900 1600 0 3600 4900 6400 8100]
    e= {1 2 3 4 5 6 7 8 9 10}
    


    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: How to solve this set problem?

    Posted 12/25/11 07:35 PM

    Originally posted by: SystemAdmin


    Thank you for bringing this to our notice. I have let the developers know about the behavior. In the meanwhile, please continue to use the format that works.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer