help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Re: ordered and ord in MathProg?


From: Noli Sicad
Subject: Re: [Help-glpk] Re: ordered and ord in MathProg?
Date: Tue, 9 Feb 2010 11:19:47 +0700

Here is the SCPc.mod with the 'last' AMPL function.

Noli
~~~~~
# Model SCPc
# SCPc.mod

set PP; #ordered;              # Set of SKU Numbers
set TT; #ordered;              # Set of Time Buckets
set KK; #ordered;              # Set of Recources

param ord{t in TT} := substr(t,1,1);

param P integer := card(PP); # Number of SKUs
param T integer := card(TT); # Number of Time Buckets (days)
param K integer := card(KK); # Number of Recources
param M >= 0;                # Large Number
param IT <=1, >=0;           # Inventory Tolerance at the end

param LT {PP} integer;      # Lead Time
param R {PP, PP} integer;   # number of SKUs i to make one SKU j
param D {PP, TT} integer;   # Ext. Demand for an item in a period
param I {PP} integer;       # Beginning Inventory
param U {PP, KK};           # fraction of rec. k needed by one SKUp
param F {KK, TT};           # Max frac. of k that can be added in t
param S {PP, KK};           # Frac. of k used to changover to SKU i
param W {PP, PP};           # Waste of i to setup changeover to j
param H {PP};               # per period holding cost for SKU i
param C {PP};               # Total changeover cost for SKU i
param O {KK,TT};            # Marginal cost per fraction added
param A {PP};               # Per Period tardiness cost for ext. d.

var d {PP, TT} binary;      # production indicator
var x {PP, TT} >=0;         # number of SKUs to produce
var y {KK,TT}  >=0;         # "overtime" fraction of rec. k in t
var iplus {PP,TT} >=0;      # Inventory of SKU i to carry in t
var iminus {PP,TT} >=0;     # Quantity of SKU i backordered in t

minimize objective:
 sum {t in TT}
     (sum {i in PP}
          (A[i]*iminus[i,t] + H[i]*iplus[i,t]
          + C[i]*d[i,t])
     + sum {k in KK} O[k,t]*y[k,t]);

# -----------------------------------------------------------------

subject to mrp {i in PP, t in TT}:
    sum {s in TT: ord[s] <= ord[t]-LT[i]} x[i,s] + I[i]
    - sum {s in TT: ord[s]<=ord[t]}
          (D[i,s] + sum{j in PP} (R[i,j]*x[j,s] + W[i,j]*d[j,s]))
    + sum {s in TT: ord[s]<=ord[t]} D[i,s]
   >= 0;


subject to Capacity {t in TT, k in KK}:
   sum {i in PP}
       (U[i,k]*x[i,t] + S[i,k]*d[i,t]) - y[k,t]
       <= 1 ;

subject to maxFraction {k in KK, t in TT}:
   y[k,t] - F[k,t] <= 0;

subject to ProductionIndicator {i in PP, t in TT}:
   d[i,t] - x[i,t]/M >=0;

subject to Inventory {i in PP, t in TT}:
   iplus[i,t]-iminus[i,t]
   - (  (sum {s in TT: ord[s] <= ord[t]-LT[i] } x[i,s])
      + I[i]
      - sum {s in TT: ord[s]<=ord[t]}
            (D[i,s] + sum{j in PP} (R[i,j]* x[j,s] + W[i,j]*d[j,s]))
     )
   = 0;

subject to RandomProduction {i in PP}:
   sum {s in TT: ord[s] >= T-LT[i]+1}  x[i,s] = 0;

subject to InventoryTolerance {i in PP}:
   (1-IT)*I[i] <= iplus[i,last(TT)] <= (1+IT)*I[i];

data;

# data SCPc.dat

param: PP: LT := AJ8172 2     # SKUs and Lead Time
                 LQ8811 3
                 RN0098 4
                 NN1100 1
                 WN7342 12;

set TT := 1jan04              # Time Buckets
          2jan04
          3jan04
          4jan04
          5jan04
          6jan04
          7jan04
          8jan04;

set KK := HR-101              # Resources
          MT-402;


param M := 10000 ;            # Large number

param IT := 0.25 ;            # Inventory Tolerance at the end

param R :
        AJ8172 LQ8811 RN0098 NN1100 WN7342:=
AJ8172  0      0      0      0      0
LQ8811  2      0      0      0      0
RN0098  1      0      0      0      0
NN1100  0      1      0      0      0
WN7342  0      1      0      0      0;

param D:                     # external demand for i in t
        1jan04 2jan04 3jan04 4jan04 5jan04 6jan04 7jan04 8jan04 :=
AJ8172  20     30     10     20     30     20     30     40
LQ8811  0      0      0      0      0      0      0      0
RN0098  0      0      0      0      0      0      0      0
NN1100  0      0      0      0      0      0      0      0
WN7342  0      0      0      0      0      0      0      0;

param I := AJ8172 90         # Beginning Inventory of SKU i
           LQ8811 300
           RN0098 100
           NN1100 0
           WN7342 900;

param U :               # fraction of resource k needed by one i
        HR-101      MT-402  :=
AJ8172  0.00208333  0
LQ8811  0.00104166  0.00333333
RN0098  0           0
NN1100  0.000001    0
WN7342  0           0 ;


param F :                # max fraction of k that can be added i
        1jan04 2jan04 3jan04 4jan04 5jan04 6jan04 7jan04 8jan04  :=
MT-402  0.5    0.5    0.5    0.5    0.5    0.5    0.5    0.5
HR-101  0.5    0.5    0.5    0.5    0.5    0.5    0.5    0.5;


param S :                    # Frac. of k used to changeover to i
        HR-101    MT-402:=
AJ8172  0.2        0
LQ8811  0.2        0.5
RN0098  0          0
NN1100  0          0
WN7342  0          0 ;

param W :                    # Waste of i to changeover to j
        AJ8172     LQ8811  RN0098  NN1100  WN7342:=
AJ8172  0          0       0       0       0
LQ8811  10         10      0       0       0
RN0098  0          0       0       0       0
NN1100  0          0       0       0       0
WN7342  0          0       0       0       0;

param H := AJ8172 2           # per period holding cost for SKU i
           LQ8811 1
           RN0098 0.5
           NN1100 0.1
           WN7342 0.1;


param C := AJ8172 800        # total changeover cost for SKU i
           LQ8811 4200
           RN0098 1
           NN1100 1
           WN7342 1;


param O :                    # marginal cost per fraction added
        1jan04 2jan04 3jan04 4jan04 5jan04 6jan04 7jan04 8jan04  :=
MT-402  1      1      1      1      1      1      1      1
HR-101  1      1      1      1      1      1      1      1;


param A := AJ8172 400       # per period tardiness cost for e.d.
           LQ8811 100
           RN0098 4
           NN1100 4
           WN7342 4;


On 2/9/10, Noli Sicad <address@hidden> wrote:
> On 2/9/10, Andrew Makhorin <address@hidden> wrote:
>>> set TT := 1jan04                # Time Buckets
>>>           2jan04
>>>           3jan04
>>>           4jan04
>>>           5jan04
>>>           6jan04
>>>           7jan04
>>>           8jan04 ;
>>
>> Easiest way is to define TT as follows:
>>
>>    set TT := 1 2 3 4 5 6 7 8;
>>
>> in which case ord(t) = t.
>>
>
> Yes. I think these "ordered" and "ord() can rest in peace now.
> MathProg got solution for this problem.
>
> Noli
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]