(!********************************************************************* Mosel Example Problems ====================== file yldmgmt.mos ```````````````` Yield management problem Example discussed in section 8.4.2 of J. Kallrath: Business Optimization Using Mathematical Programming - An Introduction with Case Studies and Solutions in Various Algebraic Modeling Languages. 2nd edition, Springer Nature, Cham, 2021 author: S. Heipcke, June 2018 (c) Copyright 2020 Fair Isaac Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *********************************************************************!) model 'yldmgmt' uses "mmxprs" declarations NP= 6 ! No. of ports MAXCAP= 25 ! Ship's capacity RP=1..NP ! Set of ports RP1=1..(NP-1) YIELD: array(RP,RP) of real ! Yield MINREQ: array(RP,RP) of real ! Min requirements MAXREQ: array(RP,RP) of real ! Max requirements end-declarations YIELD::[.0, 20.12, 24.23, 47.23, 68.20, 59.30, .0, .0, 14.80, 24.98, 52.45, 50.12, .0, .0, .0, 39.50, 60.65, 48.23, .0, .0, .0, .0, 49.24, 28.34, .0, .0, .0, .0, .0, 20.50, .0, .0, .0, .0, .0, .0] MINREQ::[.0, 1.500, 1.000, 5.000, 1.800, 4.000, .0, .0, 4.000, 1.500, 2.500, 2.000, .0, .0, .0, 3.000, 2.300, 1.500, .0, .0, .0, .0, 1.200, 1.500, .0, .0, .0, .0, .0, 1.800, .0, .0, .0, .0, .0, .0] MAXREQ::[.0, 4.000, 5.000, 8.000, 6.000,12.000, .0, .0,10.000, 4.000, 8.000, 6.000, .0, .0, .0, 8.000, 5.000, 8.000, .0, .0, .0, .0, 2.900, 6.700, .0, .0, .0, .0, .0, 8.000, .0, .0, .0, .0, .0, .0] declarations carry: array(RP1,RP) of mpvar ! Amount carried from s to f end-declarations ! Objective: maximise total yield MaxYld:= sum(s in RP1,f in s+1..NP) YIELD(s,f)*carry(s,f) ! Capacity restrictions forall(p in 2..NP) Cap(p):= sum(s in 1..p-1,f in p..NP) carry(s,f)<= MAXCAP ! Min and max requirement bounds forall(s in RP1,f in s+1..NP) ReqMn(s,f):= carry(s,f)>= MINREQ(s,f) forall(s in RP1,f in s+1..NP) ReqMx(s,f):= carry(s,f)<= MAXREQ(s,f) ! Solve the problem maximise(MaxYld) writeln("Solution: Yield=", getobjval) forall(s in RP1) do write(" ", s) forall(f in RP-{1}) if(carry(s,f).sol>0) then write("->", f, ":", strfmt(carry(s,f).sol,-4)) else write(" ") end-if writeln end-do forall(p in 2..NP) writeln(" volume at ", p, ": ", Cap(p).act) end-model