Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Non Zeros in Transportation problem

    Posted 05/27/16 10:11 AM

    Originally posted by: sandeepsinghchauhan


    In opl transportation problem (SPARSITY)

     

    float DEMAND[Route] = ...;

     

    Demand = #[
            <bands FRA>: 300
            <coils FRA>: 0
            <plate FRA>: 0
            <bands DET>: 0
            <coils DET>: 0
            <plate DET>: 0
            <bands LAN>: 0
            <coils LAN>: 300
            <plate LAN>: 0
            <bands WIN>: 0
    ]#;

    if i want to calculate/execute in opl model the  number of non zero routes present like here nonzero in demand = 2

    Please help


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Non Zeros in Transportation problem

    Posted 05/27/16 05:55 PM

    Hi,

    let me give you an example:

    .mod

    {string} Cities =...;
    {string} Products = ...;
    float Capacity = ...;
    tuple connection { string o; string d; }
    tuple route {
      string p;
      connection e;
    }
    {route} Routes = ...;
    {connection} Connections = { c | <p,c> in Routes };
    tuple supply {
      string p;
      string o;
    }
    {supply} Supplies = { <p,c.o> | <p,c> in Routes };
    float Supply[Supplies] = ...;
    tuple customer {
      string p;
      string d;
    }
    {customer} Customers = { <p,c.d> | <p,c> in Routes };
    float Demand[Customers] = ...;

    int nbNNZdemand=sum(c in Customers) (Demand[c]!=0); // This is what you need

    execute
    {
    writeln("nbNNZdemand=",nbNNZdemand)
    };

    .dat

    Cities = { GARY CLEV PITT FRA  DET  LAN  WIN  STL  FRE  LAF };
    Products   = { bands coils plate };
    Capacity    = 625;

    Routes = {
       <bands <GARY FRA> >,
       <bands <GARY DET> >,
       <bands <GARY LAN> >,
       <bands <GARY WIN> >,
       <bands <GARY STL> >,
       <bands <GARY FRE> >,
       <bands <GARY LAF> >,
       <bands <CLEV FRA> >,
       <bands <CLEV DET> >,
       <bands <CLEV LAN> >,
       <bands <CLEV WIN> >,
       <bands <CLEV STL> >,
       <bands <CLEV FRE> >,
       <bands <CLEV LAF> >,
       <bands <PITT FRA> >,
       <bands <PITT DET> >,
       <bands <PITT LAN> >,
       <bands <PITT WIN> >,
       <bands <PITT STL> >,
       <bands <PITT FRE> >,
       <bands <PITT LAF> >,

       <coils <GARY FRA> >,
       <coils <GARY DET> >,
       <coils <GARY LAN> >,
       <coils <GARY WIN> >,
       <coils <GARY STL> >,
       <coils <GARY FRE> >,
       <coils <GARY LAF> >,
       <coils <CLEV FRA> >,
       <coils <CLEV DET> >,
       <coils <CLEV LAN> >,
       <coils <CLEV WIN> >,
       <coils <CLEV STL> >,
       <coils <CLEV FRE> >,
       <coils <CLEV LAF> >,
       <coils <PITT FRA> >,
       <coils <PITT DET> >,
       <coils <PITT LAN> >,
       <coils <PITT WIN> >,
       <coils <PITT STL> >,
       <coils <PITT FRE> >,
       <coils <PITT LAF> >,

       <plate <GARY FRA> >,
       <plate <GARY DET> >,
       <plate <GARY LAN> >,
       <plate <GARY WIN> >,
       <plate <GARY STL> >,
       <plate <GARY FRE> >,
       <plate <GARY LAF> >,
       <plate <CLEV FRA> >,
       <plate <CLEV DET> >,
       <plate <CLEV LAN> >,
       <plate <CLEV WIN> >,
       <plate <CLEV STL> >,
       <plate <CLEV FRE> >,
       <plate <CLEV LAF> >,
       <plate <PITT FRA> >,
       <plate <PITT DET> >,
       <plate <PITT LAN> >,
       <plate <PITT WIN> >,
       <plate <PITT STL> >,
       <plate <PITT FRE> >,
       <plate <PITT LAF> >
    };

    Supply = #[
          <bands GARY>: 400
          <coils GARY>: 800
          <plate GARY>: 200
          <bands CLEV>: 700
          <coils CLEV>: 1600
          <plate CLEV>: 300
          <bands PITT>: 800
          <coils PITT>: 1800
          <plate PITT>: 300
    ]#;

    Demand = #[
          <bands FRA>: 0
          <coils FRA>: 0
          <plate FRA>: 0
          <bands DET>: 300
          <coils DET>: 750
          <plate DET>: 100
          <bands LAN>: 100
          <coils LAN>: 0
          <plate LAN>: 0
          <bands WIN>: 75
          <coils WIN>: 250
          <plate WIN>: 50
          <bands STL>: 650
          <coils STL>: 950
          <plate STL>: 200
          <bands FRE>: 225
          <coils FRE>: 850
          <plate FRE>: 100
          <bands LAF>: 250
          <coils LAF>: 500
          <plate LAF>: 250
    ]#;

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Non Zeros in Transportation problem

    Posted 05/28/16 12:51 AM

    Originally posted by: sandeepsinghchauhan


    Thanks for your valuable reply

    Actually i want to know number of zeros in terms of cities and i don't want to sum over Customers

    int nbNNZdemand[ e in cities] =  (c in Customers) (Demand[c]!=0);                                                                                                  
     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Non Zeros in Transportation problem

    Posted 05/28/16 12:21 PM

    Ok then if you adapt what I wrote to

    float DEMAND[Route] = ...;

    you get

    int nbNNZdemand=sum(r in Route) (DEMAND[r]!=0);

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer