Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  MILP Path Planning - Trigonometric Functions

    Posted 12/14/11 07:02 AM

    Originally posted by: SebastianClauss


    I'm currently working on implementing a MILP path-planning algorithm using CPLEX as the optimizing tool.

    I found following AMPL code on http://seis.bris.ac.uk/~aeagr/software.html, based on their elaborate description in their publications.
    As I understand, IBM stopped the support for AMPL. Further more AMPL doesn't propose a C++ API for interfacing with other software.
    That's why I'm trying to implement the code in OPL for me to test and modify it directly in the CPLEX IDE and to access it via API later on.

    For me it seems, that the formulation at hand is a 'normal' MILP problem, which OPL should be able to handle. But I can't find a way to implement the trigonometric functions without encountering errors.
    As AMPL uses CPLEX as a solver, I don't think the difficulty is for CPLEX to include the constraint, but it's rather my lack of knowledge regarding OPL implementation.

    
    ...   minimize arr: sum
    {t in 1..Nt
    } t*a[t] + gamma*sum
    {t in 1..(Nt-1)
    } fm[t];   # initial conditions   subject to initpos
    {i in 1..2
    }: r[i,1] = ri[i];   subject to initvel
    {i in 1..2
    }: v[i,1] = vi[i];   # system   subject to dynamics
    {t in 1..(Nt-1), i in 1..2
    }: v[i,t+1] = v[i,t] + f[i,t]*dt;   subject to kinematics
    {t in 1..(Nt-1), i in 1..2
    }: r[i,t+1] = r[i,t] + v[i,t]*dt + 0.5*f[i,t]*dt*dt;   # force limits   subject to maxforce1
    {i in 1..Nc
    }: f[1,1]*cos(i*2*pi/Nc) + f[2,1]*sin(i*2*pi/Nc) <= Fmax;   subject to maxforce2
    {i in 1..Nc
    }: f[1,2]*cos(i*2*pi/Nc) + f[2,2]*sin(i*2*pi/Nc) <= Fmax - Fm[1];   subject to maxforce3
    {t in 3..(Nt-1), i in 1..Nc
    }: f[1,t]*cos(i*2*pi/Nc) + f[2,t]*sin(i*2*pi/Nc) <= Fmax - Fm[2];   # force magnitude   subject to forcemag
    {t in 1..(Nt-1), i in 1..Nc
    }: f[1,t]*cos(i*2*pi/Nc) + f[2,t]*sin(i*2*pi/Nc) <= fm[t];   # speed limits   subject to maxspeed1
    {i in 1..Nc
    }: v[1,1]*cos(i*2*pi/Nc) + v[2,1]*sin(i*2*pi/Nc) <= Vmax;   subject to maxspeed2
    {i in 1..Nc
    }: v[1,2]*cos(i*2*pi/Nc) + v[2,2]*sin(i*2*pi/Nc) <= Vmax - Vm[1];   subject to maxspeed3
    {t in 3..Nt, i in 1..Nc
    }: v[1,t]*cos(i*2*pi/Nc) + v[2,t]*sin(i*2*pi/Nc) <= Vmax - Vm[2];   ...
    


    My Questions are:
    • Does OPL/CPLEX allow for trigonometric functions in constraints, as AMPL does?
    • If it doesn't: Are there known work arounds for these formulations?
    • If not: Do you know a way to solve the problem with another tool in the Academic Initiative?

    Thanks for your help,

    Sebastian Clauss
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: MILP Path Planning - Trigonometric Functions

    Posted 12/14/11 07:41 AM
    Hi

    indeed cos is available in OPL thru the scripting part.

    Let me give you an example:

    float a=0;
     execute
     {
      writeln(Math.cos(a)); 
     }
    


    So if you need cos in the constraints you may use something like

    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 OPL constraints

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer