Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Capacity Constraint

  • 1.  Capacity Constraint

    Posted Tue October 22, 2019 08:40 AM

    Originally posted by: sandeepsinghchauhan


    Hi

    I have total 100 available trucks and my objective is to minimize the number of trucks. I have 100 orders and each order has 50 lb weight. The maximum weight I can put in a truck is 500 only. How can I formulate the capacity constraint that helps me to evaluate the minimum number of trucks. Please help

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Capacity Constraint

    Posted Tue October 22, 2019 09:46 AM

    Hi,

    you could use the pack constraint.

    using CP;
    int m = 100;
    int n = 100;

    dvar int l[j in 1..m] in 0..500;
    dvar int p[i in 1..n] in 1..m;
    dvar int nb;

    int w[1..n] = [i : 50 | i in 1..n];  

    minimize nb;
    subject to {
       nb==m-count(l,0);
      pack(l, p, w, nb);
     
    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer