Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  using trigonometric function to define variable expressions

    Posted 01/24/12 05:25 PM

    Originally posted by: Jutto


    Hello

    Using CP, is it possible to include trigonometric functions for defining variable expressions.
    For instance:

    dexpr float deltaYs2 in Segments = ((lines2*cos(angles2)));

    I currently don't understand how such mathematical expressions can be used.

    Thanks for the help, Martin
    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: using trigonometric function to define variable expressions

    Posted 01/26/12 09:31 AM

    Originally posted by: ol


    Hello,
    a float expression can be used in an objective function, in another expression, or in a constraint. For instance, you can see the example floatexpr.mod:

    using CP;

    dvar int i in 1..100;
    dvar int j in 1..100;
    dvar int k in 1..99;

    dexpr float kf = k/100;
    dexpr float arhttp://i in 1..10 = k/i;

    minimize kf + sum(i in 1..10)ar[i];

    subject to {
    i*(1+kf) == j;
    }

    However, trigonometric functions are not available in OPL, and you need to use the C++ API.

    Regard,
    Olivier
    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: using trigonometric function to define variable expressions

    Posted 01/27/12 03:25 AM

    Originally posted by: Jutto


    Thanks for your help, Oliver

    This is what I do not yet understand; what do I need to do to implement the C++ API into my OPL script and integrate a trigonometric function into an expression?

    Best Regards, Martin
    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: using trigonometric function to define variable expressions

    Posted 01/29/12 02:21 PM
    Hi,

    what you can do also is to compute the trigonometric values in execute blocks and then use those values in the subject to part.

    
    
    
    int Nc=100; 
    
    float pi=3.14; range r=0..Nc; 
    
    float cosValueForI[r]; execute 
    { 
    
    for(var i in r) cosValueForI[i]=Math.cos(i*2*pi/Nc); 
    }
    


    And then you can use cosValueForI in your constraints.

    Regards
    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: using trigonometric function to define variable expressions

    Posted 01/29/12 07:04 PM

    Originally posted by: Jutto


    Thanks a lot, Alex

    I will try that out right away.

    Best regards, Martin
    #ConstraintProgramming-General
    #DecisionOptimization