Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Operator not available for dvar float * {boolean}.

    Posted Wed April 23, 2014 06:55 AM

    Originally posted by: Amani_Jerbi


    Hi, I would like to multiply a binary coefficient with a float decision variable, however there is always an error that appears. I need help please.


    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: Operator not available for dvar float * {boolean}.

    Posted Wed April 23, 2014 07:38 AM

    It would be much easier to help you if you showed us the offending statement in the model and the definition of the variables/data involved in that statement.

    From the error message it seems as if you are trying to multiply a decision variable with a boolean? Have you tried using 0 and 1 instead of false and true, so that you would actually multiply by a number and not by boolean.

    In general, for questions involving the OPL modeling language you should turn to the OPL Forum.


    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Operator not available for dvar float * {boolean}.

    Posted Wed April 23, 2014 07:58 AM

    Originally posted by: Amani_Jerbi


    Thank you for your reply, I will turn to the OPL Forum for further questions. 
    However, this is my code 
     

    {string} Platforms = ...;
    {string} Satellites = ...;
    {string} Products = ...;
    {string} Demand_zone=...;
    {string} zone=...;
    int Ce =...; /* carbon emission index*/
     
    int NbPeriods = ...;
    range Days = 1..NbPeriods;
    {float} Budget= ...;
    {string} Vehicles=...;
      
    tuple route { 
      string origin; /*origin platform*/
      string destination; /*destination satellite*/
      string zone; /*destination zone*/
    }
    {route} Route = ...;
    float charge[Route];
    int distance [Route];
     
    int capacity [Vehicles]=...; 
    float cost [Vehicles]=...;
     
    {float} Demand[Products][Days][Demand_zone]=...;
    {int} Gamma[Route][Demand_zone] = {0,1};
    {int} Alpha[Route][Satellites] = {0,1};
    {float} emission= ...;
     float penalty_fee[zone];
    float Rho[Route] = ...;
     int E = (penalty_fee[zone]*(Rho[Route]* distance [Route]*Ce));

     

    /*Decision variables*/
    dvar boolean X[Route][Vehicles][Days];
    dvar boolean Y[Route][Vehicles][Days];
    dvar float F[Products][Route][Days];
     
     
    /*Objective function*/
    minimize 
    sum(k in Route, v in Vehicles, t in Days)
      (cost[v]* (X[k][v][t]+Y[k][v][t])+
      sum(k in Route, v in Vehicles, t in Days) charge[k] *(X[k][v][t]+Y[k][v][t]))+
      sum(k in Route, v in Vehicles, t in Days, z in zone)  (X[k][v][t]+Y[k][v][t]);
    /*Constraints*/
    subject to 
    {forall( t in Days )
        ctDemandFulfillement:
          sum (k in Route,l in Demand_zone,s in Satellites, p in Products) 
          F[p][k][t] * Alpha[k][s] == Demand [l][p][t];
    forall (v in Vehicles, t in Days, p in Products, k in Route)
      ctCapacityFirstEchelon:
        forall( t in Days, v in Vehicles)
          sum (k in Route,l in Demand_zone,s in Satellites, p in Products) 
          F[p][k][t] * Alpha [k][s] <= capacity[v];
          
    forall (v in Vehicles, t in Days, p in Products, k in Route)
      ctCapacitySecondEchelon:
        forall( t in Days, v in Vehicles)
          sum (k in Route,l in Demand_zone,s in Satellites, p in Products) 
          Demand[l][p][t] * Gamma [k][l] <= capacity[v];   
          
    forall (v in Vehicles, t in Days, p in Products, k in Route)
      ctBugdet:
        forall( t in Days, v in Vehicles)
          sum (k in Route,l in Demand_zone,s in Satellites, p in Products) 
          cost[v] * Y[k][v][t] <=  Budget;         
               
    }

    The error is always attached to the coefficient "Alpha and Gamma" , also i would like to know how to calculate a formula like in  int E = (penalty_fee[zone]*(Rho[Route]* distance [Route]*Ce)); â€‹ It also shows an error.
     

    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: Operator not available for dvar float * {boolean}.

    Posted Wed April 23, 2014 10:59 AM

    I am not an OPL expert but I think I spotted at least one problem in your code:

    {int} Alpha[Route][Satellites] = {0,1};

    With this definition (does this even compile? I get an error if I write the line like that) the element Alpha[k][s] is a set of integers and not a plain integer. So

    F[p][k][t] * Alpha[k][s] == Demand [l][p][t];

    attempts to multiply a decision variable with a set -- and that is not supported. I think what you want is

    int Alpha[Route][Satellites] = {0,1};

    (without curly braces around 'int') so that element Alpha[k][s] is a plain integer. And I think you need something else than '{0,1}' as initializer for Alpha, the above line still does not compile for me.

    As for the expression E, I think you want something like this:

    dexpr int E[z in zone][r in Route] = (penalty_fee[z] * (Rho[r] * distance[r] * Ce));

    With that definition you can write E[z][r] in your model (with z from zone and r from Route).


    #DecisionOptimization
    #MathematicalProgramming-General


  • 5.  Re: Operator not available for dvar float * {boolean}.

    Posted Wed April 23, 2014 11:02 AM

    Originally posted by: Amani_Jerbi


    Thank you so much for your help. 


    #DecisionOptimization
    #MathematicalProgramming-General


  • 6.  Re: Operator not available for dvar float * {boolean}.

    Posted Wed April 23, 2014 11:26 AM

    By the way, did you look through the various OPL examples that are shipped with CPLEX Optimization Studio? They may help to understand things a little better. For example, that dexpr thing is used in examples talents.mod and floatexpr.mod (OK, you need to know what you are looking for but just browsing through the examples may already teach you a lot).


    #DecisionOptimization
    #MathematicalProgramming-General


  • 7.  Re: Operator not available for dvar float * {boolean}.

    Posted Wed April 23, 2014 11:52 AM

    Originally posted by: Amani_Jerbi


    Yes, now I've opened it and the problem was solved! Thanks to you.


    #DecisionOptimization
    #MathematicalProgramming-General