(!****************************************************** Mosel Example Problems ====================== file pricebrai2.mos ``````````````````` Modeling price breaks: All item discount pricing - formulation as piecewise linear expression - (c) 2021 Fair Isaac Corporation author: S. Heipcke, July 2021 *******************************************************!) model "All item discount (pwlin)" uses "mmxnlp" declarations NB = 3 ! Number of price bands BREAKS = 1..NB COST: array(BREAKS) of real ! Cost per unit x: mpvar ! Number of items bought B: array(0..NB) of real ! Break points of cost function end-declarations DEM:= 150 ! Demand B:: [0, 50, 120, 200] COST:: [ 1, 0.7, 0,5] ! Objective: Specification as list of piecewise linear segments TotalCost:= pwlin(x, union(i in 1..3) [B(i-1), COST(i)*B(i-1), B(i), COST(i)*B(i)]) ! Objective: Specification as list of points ! TotalCost:= pwlin(x, union(i in 1..3) [B(i-1), COST(i)*B(i-1), B(i), COST(i)*B(i)]) ! Meet the demand x = DEM ! Solve the problem minimize(TotalCost) ! Solution printing writeln("Objective: ", getobjval, " (price per unit: ", getobjval/DEM, ")") forall(i in BREAKS) writeln("Interval ", i, ": ", if(x.sol>=B(i-1) and x.sol<=B(i),x.sol,0), " (price per unit: ", COST(i), ")") end-model