Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  help! :Function operator/(dvar,dvar float) not available in context CPLEX.

    Posted 02/07/12 05:56 AM

    Originally posted by: james87


    Dear guys,

    Im trying to write a piece of code that optimize a ratio of two decision variables. apparently the division of variables is not allowed. I tried to linearised this fractional programming problem but apparently 1/dvar is also an invalid declaration in opl. Please help! im desperate.
    Heres part of the code that i had which did not work

    ********************************************************************************************************************
    int SampleN=5;
    int AssetN=3
    dvar float+ x[1..AssetN][1..PeriodN][1..SampleN];
    dvar float+ w_end[1..SampleN];
    dvar float+ float Bsum[1..SampleN];
     
    Minimize
    sum(k in 1..SampleN) 1/SampleN*(w_end[k]/Bsum[k]);
     
    forall(k in 1..SampleN)
    Bsum[k] == sum(i in 1..AssetN)Beta[i]*(x[i][PeriodN][k]/sum( j in 1..AssetN)x[j]PeriodN[k]);
    

    ********************************************************************************************************************
    Thank you!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: help! :Function operator/(dvar,dvar float) not available in context CPLEX.

    Posted 02/07/12 06:25 AM

    Originally posted by: SystemAdmin


    W.r.t. your constraint: what is
    Bsum[k] == .... sum( j in 1..AssetN)x[j]PeriodN[k]);
    


    PeriodN[k] is undefined, isn't it?

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: help! :Function operator/(dvar,dvar float) not available in context CPLEX.

    Posted 02/07/12 07:01 AM

    Originally posted by: james87


    Thanks nobert again for the reply

    thanks for the reply. Correct me if I am wrong, but doesn't

    for( k in 1..SampleN)
    define the k in the immediately following statement?
    regardless I can change the whole statement to

    int SampleN=5;
    int AssetN=3
    int Beta[1..AssetN] = ...;
     
    dvar float+ x[1..AssetN][1..PeriodN][1..SampleN];
    dvar float+ w_end[1..SampleN];
    dvar float+ Bsum[1..SampleN];
     
     
    Minimize
    sum(k in 1..SampleN) 1/SampleN*(w_end[k]/Bsum[k]);
     
    forall(k in 1..SampleN)
    Bsum[k] == sum(i in 1..AssetN)Beta[i]* (x[i][PeriodN][k]/w_end[k]);
     
    /* define w_end */
    forall(k in 1..SampleN)
        End_Return:
          w_end[k] == sum(i in 1..AssetN) v[i,PeriodN,k];
          // v[i][n][k] is another dvar which manages the flow of money in my stochastic program
    


    Thank you for your help! With respect to the question, do tell me if it is easier for you to look at the problem if i just upload the whole file. I thought uploading the whole code would really turn people off so i acted against that.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: help! :Function operator/(dvar,dvar float) not available in context CPLEX.

    Posted 02/07/12 09:12 AM

    Originally posted by: SystemAdmin


    > Correct me if I am wrong, but doesn't for( k in 1..SampleN)

    You are right, but there were brackets missing, and PeriodN was not defined.

    Anyway, your speculation that CPLEX does not support expresions of the
    form x/y or 1/y where x and y are decision variables is correct.
    (this is a nonlinear formulation)
    You should either
    (*) think about a reformulation of the problem in order to get a linear objective and linear constraints to use CPLEX
    or
    (*) use the CP-engine.

    The following code snippet
    using CP;
     
    int SampleN=5;
    int AssetN=3;// ; inserted
    int PeriodN = 3; // added this line
    int Beta[1..AssetN] = [1,2,3];
     
    dvar int+ x[1..AssetN][1..PeriodN][1..SampleN];
    dvar int+ w_end[1..SampleN];
    dvar int+ Bsum[1..SampleN];
     
     
    minimize  // "minimize" instead if "Minimize"
    sum(k in 1..SampleN) 1/SampleN*(w_end[k]/Bsum[k]);
     
    subject to{ // added to code
    forall(k in 1..SampleN)
    Bsum[k] == sum(i in 1..AssetN)Beta[i]* (x[i][PeriodN][k]/w_end[k]); 
    }
    

    is at least valid but far away from being easily solvable.

    Hope this helps in any way.

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: help! :Function operator/(dvar,dvar float) not available in context CPLEX.

    Posted 02/07/12 11:45 AM

    Originally posted by: james87


    thanks again for the code. now things are feasible. I actually tried using CP in OPL after reading another thread but like you say, its far from being solvable. After hours of coding, no solution was found yet. I'm really new to constraint programming so I wonder if you have any tricks and tips that you can share in the context of my problem? I read that preprocessing and some definitions on optimality will help?

    thanks you so much for your help!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer