Decision Optimization

 View Only
Expand all | Collapse all

CPLEX(default) cannot extract expression

ALEX FLEISCHER

ALEX FLEISCHERSun January 21, 2018 08:11 AM

Archive User

Archive UserWed May 30, 2018 09:26 AM

ALEX FLEISCHER

ALEX FLEISCHERWed May 30, 2018 02:42 PM

  • 1.  CPLEX(default) cannot extract expression

    Posted Sun January 21, 2018 06:48 AM

    Originally posted by: skyskyhuanghuang


    Hi all,

    I am a newbie in using OPL,i have written like this:

    int M=...;
    float P2=...;
    float H1[1..M][1..M]=...;
    float B0=...;
    float n0=...;
    dvar float+ Yji1[1..M][1..M]in 0..1 ;
    //dvar int Yji1[1..M][1..M] in 0..1 ;
     
    maximize
    B0*sum(i in 1..M)(
         log(1+sum(j in 1..M)(
                 P2*H1[j][i]*Yji1[j][i]/ 
                   (n0+sum(n,q in 1..M)P2*H1[n][i]*Yji1[n][q]
                     -P2*H1[j][i]*sum(k in 1..M)Yji1[j][k])
               )
             )/log(2)
       );
    When I run the code i get errors like:

    CPLEX(default) cannot extract expression: maximize (sum(i in 1..3) (ln(sum(j in 1..3) ((H1[j][i]*0.126)*Yji1[j][i]) / (sum(n in 1..3, q in 1..3) (H1[n][i]*0.126)*Yji1[n][q]+((H1[j][i]*0.126)*(sum(k in 1..3) Yji1[j][k]))*(-1)+6.3e-13)+1) / 2.30258509299405) / (ln(2) / 2.30258509299405))*20000000. 20180120.mod /Solve 20:1-30:5 /home/sky/opl/Solve/20180120.mod OPL Problem Marker

    When I remove the sum of noise power behind, the procedure is right, and this is why

    maximize
    B0*sum(i in 1..M)(
         log(1+sum(j in 1..M)(
                 P2*H1[j][i]*Yji1[j][i]/n0 
                   //(n0+sum(n,q in 1..M)P2*H1[n][i]*Yji1[n][q]
                     //-P2*H1[j][i]*sum(k in 1..M)Yji1[j][k])
               )
             )/log(2)
       );

     I dont know how to fix this or other problems in the code.



  • 2.  Re: CPLEX(default) cannot extract expression

    Posted Sun January 21, 2018 08:11 AM

    Hi,

    you get that error because log is not linear.

    what you could do is use CPO.

    See for example

    using CP;
     
     int scale=10000;
     
     
     int M=2;
    float P2=1.2;
    float H1[i in 1..M][j in 1..M]=2;
    float B0=1;
    float n0=2;

    //dvar int Yji1[1..M][1..M] in 0..1 ;

    dvar int scaleYji1[1..M][1..M] in 0..scale ;
    dexpr float Yji1[i in 1..M][j in 1..M]=scaleYji1[i][j]/scale;
     
    maximize
    B0*sum(i in 1..M)(
         log(1+sum(j in 1..M)(
                 P2*H1[j][i]*Yji1[j][i]/
                   (n0+sum(n,q in 1..M)P2*H1[n][i]*Yji1[n][q]
                     -P2*H1[j][i]*sum(k in 1..M)Yji1[j][k])
               )
             )/log(2)
       );
       
       subject to
       {
          
       }

    regards



  • 3.  Re: CPLEX(default) cannot extract expression

    Posted Mon January 22, 2018 01:52 AM

    Originally posted by: skyskyhuanghuang


    thank you very much.But after changing the calculation, time becomes longer, how to solve it?and the decision variable becomes scaleYji1,i just want decision variable to be Yji1.How can i sovle it ?



  • 4.  Re: CPLEX(default) cannot extract expression

    Posted Mon January 22, 2018 02:50 AM

    Hi,

    you may set a time limit

    execute
    {

    cp.param.timelimit=60;
    }

    You may also stay with CPLEX but then you would have to linearize the log

    See https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=dd4fa84b-4bcb-4be4-8887-0b55e8c8f7f2&ps=25

    regards

     

     



  • 5.  Re: CPLEX(default) cannot extract expression

    Posted Mon January 22, 2018 09:51 PM

    Originally posted by: skyskyhuanghuang


    Thanks for the code.

    execute
    {

    cp.param.timelimit=60;
    }

    but for cplex,It does not seem to work.I don now why.Also, How to set the emphasismip parameter in the mod file to 1?

    Thank you,

     



  • 6.  Re: CPLEX(default) cannot extract expression

    Posted Tue January 23, 2018 01:40 AM

    Hi

    with linear programming:

    cplex.tilim=60;

    cplex.mimpemphasis=1;

    in an execute block

    regards



  • 7.  Re: CPLEX(default) cannot extract expression

    Posted Tue January 23, 2018 03:52 AM

    Originally posted by: skyskyhuanghuang


    Thank you.



  • 8.  RE: Re: CPLEX(default) cannot extract expression

    Posted Mon March 21, 2022 03:43 PM
    Hi,

    I am getting similar error in my code, could you please help me out in solving
    thanks in advance

    int max_k=...;
    int max_t=...;
    range K=1..max_k;
    range T=1..max_t;
    int d[K][T]=...;
    int p[K][T]=...;
    int q[K][T]=...;
    int h[K][T]=...;
    int a[K]=...;
    int M[K][T];
    int C=...;
    float e[K]=...;
    dvar int x[K][T];
    dvar int s[K][T];
    dvar boolean y[K][T];
    minimize sum(k in K,t in T)p[k][t]*x[k][t]+sum(k in K,t in T)q[k][t]*y[k][t]+sum(k in K,t in T)h[k][t]*s[k][t];
    subject to {
    forall(t in T, k in K){
    s[k][t-1]+x[k][t]==d[k][t]+s[k][t];
    }
    forall(k in K){
    s[k][0]==0;
    }
    forall(t in T, k in K){
    x[k][t]<=M[k][t]*y[k][t];
    }
    forall(k in K, t in T){
    M[k][t]==9999999999;
    }
    forall(t in T){
    sum(k in K)e[k]*s[k][t]<=C;
    }
    }

    ------------------------------
    Vaidik Miyani
    ------------------------------



  • 9.  RE: Re: CPLEX(default) cannot extract expression

    IBM Champion
    Posted Mon March 21, 2022 05:36 PM
    In your first constraint, when t = 1 you refer to s[k][0], which does not exist.

    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 10.  Re: CPLEX(default) cannot extract expression

    Posted Wed May 30, 2018 09:26 AM
      |   view attached

    Originally posted by: MaxImal14582906


    Hey,

     

    I get the same error and i have a similar problem. My Optimization Problem looks like this:

    My code looks like this:

    //parameters

     

    int m=...; //number of machines

     

    int n=...; //number of time steps in overall simulation

     

    int p=...; // number of time steps in power cycle

     

    float Pmin=...; //minimum of production

     

    float Pmax=...; //maximum of production

     

     

     

    range machines = 1..m;

     

    range time = 1..n;

     

    range ptime = 1..p;