Decision Optimization

Decision Optimization

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

 View Only
  • 1.  forall & If conditionals

    Posted Fri June 02, 2017 10:49 AM

    Originally posted by: RisteGolchev


    Hello all,
    I have this problem while trying to find a solution for a resource constraint scheduling problem. Whenever I put dvar as a condition in a forall loop or if condition I have the error that states "Decision variable (or expression) "S" not allowed". 
       

        range activity = 1..16;
        dvar float+ S[activity];

        dvar float+ rd[jobs];
        
        forall (i in activity)
         forall (t in T:S[i]<=t<=S[i]+D[i]) //boolean b 
                  b[i][t]==1;
          
        forall (t in T)
          forall (k in R)
            sum (i in activity)b[i][t]*V[i][k]<=Rk[k];//human resources constraint
            
          forall (j in jobs)
          forall (t in T:rd[j]<=t<=S[maxact[j]])//boolean y
          y[j][t]==1;


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: forall & If conditionals

    Posted Fri June 02, 2017 10:59 AM

    As the error message suggests, it is not allowed to have decision variables in these places (this is stated somewhere in the manual). You can work around this by using logical constraints, for example

    forall (t in T:S[i]<=t<=S[i]+D[i]) b[i][t]==1;

    could be written as

    forall (t in T) (S[i]<=t && t<=S[i]+D[i]) => b[i][t]==1;

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: forall & If conditionals

    Posted Fri June 02, 2017 01:25 PM

    Originally posted by: RisteGolchev


    Perfect, I fixed the problem. Now, I have infeasible solution feedback from Cplex :;D 


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: forall & If conditionals

    Posted Wed June 07, 2017 02:24 AM

    In case this is unexpected, there is a tutorial about infeasibility here.
     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: forall & If conditionals

    Posted Fri June 02, 2017 11:33 AM

    Let me take this as an opportunity to mention that CPLEX Optimization Studio comes with a Constraint Programming engine that is specifically engineered to solve scheduling problems. Here's what a very simple RCPSP looks like using CP, taken from the OPL example sched_rcpsp.mod:

     

    using CP;

    int NbTasks = ...;
    int NbResources = ...;
    range resourceIds = 0..NbResources-1;
    int Capacity[r in resourceIds] = ...;

    tuple Task {
      key int id;
      int     processingTime;
      int     demands[resourceIds];
      {int}   successors;
    }
    {Task} Tasks = ...;

    dvar interval intervalVars[t in Tasks]  size t.processingTime;

    cumulFunction resourceUsage[r in resourceIds] =
      sum (t in Tasks: t.demands[r]>0) pulse(intervalVars[t], t.demands[r]);

    minimize max(t in Tasks) endOf(intervalVars[t]);
    subject to {
      forall (r in resourceIds)
        resourceUsage[r] <= Capacity[r];
      forall (t1 in Tasks, t2id in t1.successors)
        endBeforeStart(intervalVars[t1], intervalVars[<t2id>]);
    }

     

    You will find an introduction to all the concepts at https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.ide.help/refcppopl/html/introduction.html


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: forall & If conditionals

    Posted Fri June 02, 2017 12:40 PM

    Originally posted by: RisteGolchev


    Hello all,

     

    First of all thank you for your fast replies regarding my problem. @DanielJunglas 548c249b-bb6b-42f6-99b8-f0376c80829e  Thank you so much, For the particular line that you wrote ​, It works properly. Now , I have the same issue with the rd that doesn't work with your solution :D

    ( forall (t in T:rd[j]<=t<=S[maxact[j]])//boolean y
          y[j][t]==1;

    But anyway, i think that i have problem with the [maxact] argument that i need to fix.

    Xavier, thank you very much. However, for this university project work , I have to use MIP. 

    (I already managed to do a model by using CP)

     


    #CPLEXOptimizers
    #DecisionOptimization