Decision Optimization

Decision Optimization

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

 View Only
  • 1.  request optimization

    Posted Wed March 13, 2013 03:48 PM

    Originally posted by: SystemAdmin


    Hey
    I am a new user for Cplex,
    I started writing my first code using OPL but the result is no value
    the following is my code:
    /*********************************************
    * OPL 12.5 Model
    * Author: mimo
    * Creation Date: Mar 5, 2013 at 11:59:33 PM
    *********************************************/
    using CP;

    {string} jobs =...;
    {string} links =...;
    {string} wavelengths=... ;
    {string} paths =...;
    int ajobs,paths=... ;
    int blinks,paths=... ;
    int djobs=... ;
    int h =...;
    int Xjobs,paths,wavelengths;
    int Yjobs,jobs;
    int J =... ;
    int rjobs=...;
    //int val;

    //dvar float+ Sjobs;
    //dvar float+
    dvar int Stjobs ;
    //dvar int rjobs;
    constraint c1 ;
    constraint c2 ;
    constraint c3 ;
    constraint c4 ;
    constraint c5 ;
    constraint c6 ;
    constraint c7;
    constraint c8;
    constraint c9;
    constraint c10;
    constraint c11;
    constraint c12;
    constraint c13;
    constraint c14;

    execute {
    cp.param.SearchType = "DepthFirst";
    }
    minimize
    sum (j in jobs) (St[j]-r[j]) ;

    subject to {

    forall (j in jobs)
    c1=
    {
    St[j]>=r[j] ;
    }

    forall(j in jobs)
    c2=
    {
    forall ( k in jobs:k!=j)
    {
    c3=
    (Yj,k + Yk,j) == 1;
    }
    }
    forall(j in jobs)
    c4=
    {
    sum (p in paths) sum(w in wavelengths) (Xj,p,w*aj,p) ==1;
    }
    // put constraints for below for's
    forall (j in jobs)
    c5=
    {
    forall(p in paths)
    { c6=
    forall(w in wavelengths)
    { c7=
    0<=Xj,p,w<=1;
    }
    }
    }

    forall(j in jobs,k in jobs:k!=j)
    c8=
    {
    forall(k in jobs:k!=j)
    { c9=
    0<= Yj,k <=1;
    }
    }

    forall(j in jobs)
    c10=
    {
    St[j]>=0;
    r[j]>=0;
    }

    forall(j in jobs)
    c11 =
    {
    forall(k in jobs:k!=j)
    { c12=
    forall(l in links)
    { c13=
    forall(w in wavelengths)
    { c14=
    ((sum ( p in paths)(d[j]*bl,p*Xj,p,w + h*bl,p*Xj,p,w+h*bl,p*Xk,p,w))
    + St[j] - St[k] + h*Yj,k) <=3*h;
    }
    }
    }
    }
    }
    main{
    thisOplModel.generate();
    cp.startNewSearch();
    while(cp.next() )
    {
    thisOplModel.postProcess();
    }
    }
    please can anybody help me,
    thanks
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: request optimization

    Posted Thu March 14, 2013 03:20 AM
    Hi,

    maybe your model is unfeasible.
    Can you attach your .mod and .dat?

    Regards
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: request optimization

    Posted Thu March 14, 2013 11:50 AM

    Originally posted by: SystemAdmin


    Hello,

    I have attached you my .dat file and in the following message I will attach you .mod file,
    Thanks a lot for your help,
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: request optimization

    Posted Thu March 14, 2013 11:50 AM

    Originally posted by: SystemAdmin


    This is my .mod file
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: request optimization

    Posted Thu March 14, 2013 12:19 PM
    Hi,

    if you comment your constraints c2 and c4 then you get a solution.

    So there could be an issue with those 2 constraints

    regards
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: request optimization

    Posted Thu March 14, 2013 12:28 PM

    Originally posted by: SystemAdmin


    Thanks a lot Alex,
    I will try to fix them.

    BR
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: request optimization

    Posted Thu March 14, 2013 01:02 PM

    Originally posted by: SystemAdmin


    In the constraints c2 and c4, is there any syntax error?

    If I comment c2 and c4 and run the code, I will be warned that:
    "Element c1 might not be used, similarly for the other constraints"
    Does this mean that the constraints are not being used?

    Thanks
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: request optimization

    Posted Thu March 14, 2013 02:33 PM

    Originally posted by: SystemAdmin


    The constraints are not being used but I can not know why.
    I have changed some constraints to see if the code will assign some values for the X and Y parameters but their values are zeros whatever the constraints are.

    Please can you help me?
    Thanks,
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: request optimization

    Posted Mon March 18, 2013 12:00 PM

    Originally posted by: ol


    Hello,

    I suspect the keyword dvar will help :-)

    
    dvar 
    
    int X[jobs,paths,wavelengths]; dvar 
    
    int Y[jobs,jobs];
    


    Regards,
    ol
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 10.  Re: request optimization

    Posted Mon March 18, 2013 01:17 PM

    Originally posted by: SystemAdmin


    Thanks a lot, I guess it is working :),

    BR
    Manar
    #DecisionOptimization
    #OPLusingCPOptimizer