Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Division operator not available in CPLEX

    Posted 04/06/15 10:48 AM

    Originally posted by: memop


    Hi. I have a nonlinear model with division constraints. But OPL gives an error message: Function operator (..) not avaliable in content CPLEX. I have searched this problem in the forum, but neither solution is not applicable for my model. The code is as follows. How would you suggest a solution way to overcome this problem? Thank you very much in advance. 

    {code}

    float CV = 0.2;
    float SCVa = 1;
    float lambda = 1/11;
    int Nbtasks = ...;
    range tasks = 1..Nbtasks;
    int Nbstations = ...;
    range stations = 1..Nbstations;
    float taskTime[tasks]=...;
    float tvariance[tasks];
    dvar float cycleTime;
     
    tuple precedence {
    int predecessor;
    int successor;
    };
     
    {precedence} Precedences = ...;
     
    int earliest[tasks] = ...;
    int latest[tasks] = ...;
     
    execute {
    for (var i in tasks)
    tvariance[i] = Math.pow((CV*taskTime[i]), 2);
    };
     
    dvar boolean assign[tasks][stations];
    dvar int+ stationLength[s in stations];
    dvar float+ SCV_d[s in stations];
    dvar float+ SCV_a[s in stations];
    dvar float+ SCV_e[s in stations];
    dvar float+ W_q[s in stations];
    dvar float+ CT[s in stations];
    dvar float+ WIP[s in stations];
    dvar float+ TH[s in stations];
     
    dexpr float rho[s in stations] = (lambda)*(stationLength[s]);
    dexpr float svariance[s in stations] = sum(i in tasks, j in stations) (tvariance[i] * (assign[i][j]==1));
    dexpr float ssigma[s in stations] = sqrt(svariance[s]);
     
    dexpr float total_W = sum(s in stations) W_q[s];
     
    minimize cycleTime;
     
    subject to {
     
    forall (t in tasks)
    eachTaskHasOneStation:
    sum (s in stations)
    assign[t][s]==1; 
     
    forall (s in stations)
    eachStationHasOneTask:
    sum (t in tasks) assign[t][s] >= 1;
     
    forall (prec in Precedences)
    precendeceConstraints:
    sum (s in stations) s*assign[prec.predecessor][s] <= sum(s in stations) s*assign[prec.successor][s];
     
    forall (s in stations)
    stationTimeConstraints:
    sum (t in tasks) (taskTime[t] * assign[t][s]) == stationLength[s];
     
    forall (s in stations)
    W_q[s] == (((SCV_a[s])+SCV_e[s])/2) * (rho[s]/(1-rho[s])) * stationLength[s];
     
    SCV_a[1] == SCVa;
    forall (s in stations)
    SCV_d[s] == SCV_e[s] * (rho[s]^2) + SCV_a[s] * (1-(rho[s]^2));
     
    forall (s in 2..Nbstations)
    SCV_a[s] == SCV_d[s-1];
     
    forall (s in stations)
      CT[s] == stationLength[s] + W_q[s];
     
    forall (s in stations)
      WIP[s] == (((SCV_a[s])+SCV_e[s])/2) * (rho[s]/(1-rho[s]));
     
    forall (s in stations)
      TH[s] == WIP[s]/CT[s];
     
    forall (s in stations)
      SCV_e[s] == (ssigma[s]/stationLength[s])^2;
     
    }

    {code}


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Division operator not available in CPLEX

    Posted 04/07/15 02:33 AM

    Hi,

    have you tried to use CPO ?

    For that you should turn

    dvar float+ SCV_d[s in stations];
    dvar float+ SCV_a[s in stations];
    dvar float+ SCV_e[s in stations];
    dvar float+ W_q[s in stations];
    dvar float+ CT[s in stations];
    dvar float+ WIP[s in stations];
    dvar float+ TH[s in stations];

    into dexpr float.

    The keyword is

    using CP;

    in order to use CPO.

     

    Regards

     

    PS: see https://www.ibm.com/developerworks/community/forums/html/topic?id=5df70337-cf79-4328-871e-df80e570d4e2&ps=25


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Division operator not available in CPLEX

    Posted 04/07/15 05:38 AM

    Originally posted by: memop


    Thank you alex for your reply. I have tried to use CPO and the model works very well. But the computation time could be long for medium and big data sets. I think I need to develop CP model by integrating any search strategy.

    I want to improve the mathematical model of the problem as a comparision method with CP model. It is not possible to model this problem with this nonlinear structure by using CPLEX, is it? Do you think that CPO is sufficient to solve the problem? 

    Regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  RE: Re: Division operator not available in CPLEX

    Posted 06/19/20 03:56 AM
    Hye,
    I want to ask, my objective function is nonlinear. I used CP to solve it, but when I run the configuration of the file, the solution is not an optimal solution as in CPLEX.  How can I solve the nonlinear problem using CPLEX rather than CP? Here is my coding:

    using CP;
    int scale=1000;
    {string} depot=...;
    {string} customer=...;
    {string} vehicle=...;
    {string} node=...;
    int N=card(customer);
    int pr=...;
    float dist[node][node]=...;
    float fcost[depot]=...;
    float D[customer]=...;
    float R[customer]=...;
    float VC[vehicle]=...;
    float VD[depot]=...;
    dvar boolean x[node][node][vehicle];
    dvar boolean z[depot];
    dvar boolean y[depot][customer];
    dvar int u[customer][vehicle];
    dvar int scaleQ[i in depot] in 0..240000;
    dexpr float Q[i in depot]=scaleQ[i]/scale;

    dexpr float facility=sum(i in node, j in node:j!=i, k in vehicle)x[i][j][k]*dist[i][j];
    dexpr float travel=sum(i in depot)fcost[i]*z[i];
    dexpr float setup=17*sum(i in depot, j in customer)(D[j]-R[j])*y[i][j]/Q[i];
    dexpr float holdinginventory=(1/pr)*sum(i in depot)(Q[i]*pr - Q[i]*sum(j in customer)(D[j]+R[j])*y[i][j]);
    dexpr float cost=travel + facility + setup + holdinginventory;

    minimize cost;
    subject to {
    forall(j in customer) sum(i in node, k in vehicle)x[i][j][k]==1;
    forall(k in vehicle) sum(i in depot, j in customer)x[i][j][k]<=1;
    forall(k in vehicle) sum(i in node, j in customer:j!=i)D[j]*x[i][j][k]<=VC[k];
    forall(i in node, k in vehicle) (sum(j in node)x[i][j][k])- (sum(j in node)x[j][i][k])==0;
    forall(i in depot) sum(j in customer)D[j]*y[i][j]<=VD[i]*z[i];
    forall(j in customer) sum(i in depot)y[i][j]==1;
    forall(l in customer, j in customer, k in vehicle) u[l][k]-u[j][k]+N*x[l][j][k]<= N-1;
    forall(i in depot, j in customer, k in vehicle) (sum(h in node)(x[i][h][k]+x[h][j][k]))-y[i][j]<=1;
    }

    ------------------------------
    Farahanim Misni
    ------------------------------



  • 5.  RE: Re: Division operator not available in CPLEX

    Posted 06/19/20 04:17 AM
    Can you please create a new question instead of reactivating a 5 year old question with a completely different model? Also add what you have tried to get rid of the problem. Maybe include the CP log that shows that the solution is not optimal or explain why a solution claimed optimal by CP is not optimal.

    ------------------------------
    Daniel Junglas
    ------------------------------