MODEL:  ! General Purchasing model (PURCHASL).
 A single customer is trying to decide
 which products should be bought from which supplier.
 Each supplier has fixed order cost and a quantity
 discount(all units) threshold. You may get a split sourcing solution;
!Keywords: Purchasing, Quantity Discount, Discount;
SETS:
 ! The suppliers;
  SUP: FC, DHURDL, DRATE,
                   DISC, YFC, YDS;
 ! The products;
  PROD: DEM;
 ! For each supplier, product combination...;
  SXP( SUP, PROD): PRICE, X;
 ENDSETS
DATA: SUP = MART STNB; FC = 1000, 0; ! Fixed cost of ordering; DHURDL = 0, 10000; ! Hurdle for winning discount; DRATE = 0, .1; ! Discount rate; PROD = PUMP GENR STBLZR; DEM = 2, 1, 30; ! Demand by product; PRICE = ! Price by supplier * product; 4450, 3100, 210, 4500, 3950, 290; ENDDATA !--------------------------------------------------------; NSUP = @SIZE(SUP); NPRD = @SIZE(PROD); ! Minimize net purchase cost of gross cost + fixed charges - discounts; [COST] MIN = @SUM( SXP( I, J): PRICE( I, J) * X( I, J)) + @SUM( SUP( I): FC( I) * YFC( I)) - @SUM( SUP( I): DISC( I)); ! Demand constraints, must buy amount needed; @FOR( PROD( J): @SUM( SUP( I): X( I, J)) >= DEM( J); ); ! Turn on fixed charge var of I if buy anything from I; @FOR( SUP( I): ! YFC is binary (0/1); @BIN( YFC( I)); @FOR( PROD( J): X( I, J) <= DEM( J) * YFC( I); ! Can only buy integer quantities; @GIN( X( I, J)); );); ! Describe the discount; @FOR( SUP( I): ! YDS is binary; @BIN( YDS( I)); ! Turn on YDS( I) if we take any discount; DISC( I) <= YDS( I) * DRATE( I) * @SUM( PROD( J): PRICE( I, J) * DEM( J)); ! If we take a discount it must be at least the minimum; DISC( I) >= DRATE( I) * DHURDL( I) * YDS( I); ! We cannot take more discount than entitled to; DISC( I) <= DRATE( I) * @SUM( PROD( J): PRICE( I, J) * X( I, J)); ); DATA: @TEXT( ) = "Amount to buy of each of 3 products from 2 suppliers:"; @TEXT( ) = @TABLE(X); ENDDATA END