![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Overview of Mosel examples for 'Business Optimization' book Description List of FICO Xpress Mosel implementations of examples discussed in the book 'J. Kallrath: Business Optimization Using Mathematical Programming - An Introduction with Case Studies and Solutions in Various Algebraic Modeling Languages' (2nd edition, Springer, Cham, 2021, DOI 10.1007/978-3-030-73237-0). List of provided model files(Examples marked with * are newly introduced in the 2nd edition, all other models have been converted from the mp-model versions that were provided with the 1st edition of the book in 1997.)
Source Files By clicking on a file name, a preview is opened at the bottom of this page. Data Files projschd.mos (!********************************************************************* Mosel Example Problems ====================== file projschd.mos ````````````````` Project scheduling problem Example discussed in section 10.2.3 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 See https://examples.xpress.fico.com/example.pl?id=projplangr for additional versions. 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 'projschd' uses "mmxprs" declarations NProj=3 ! Number of projects NMonth=6 ! Number of months to plan for RProj=1..NProj RMonth=1..NMonth PROF: array(RProj,RMonth) of real ! Resource profile: usage of resource ! by project p in its t'th month BEN: array(RProj) of real ! Benefit per month once project finished RES: array(RMonth) of real ! Amount of resource available in month t DUR: array(RProj) of integer ! Duration of project p (in months) end-declarations DUR::[3, 3, 4] PROF:: (1,1..3)[3, 4, 2] PROF:: (2,1..3)[4, 1, 6] PROF:: (3,1..4)[3, 2, 1, 2] ! Other PROF entries are 0 by default BEN::[10.2, 12.3, 11.2] RES::[5, 6, 5, 5, 4, 5] declarations x: array(RProj,RMonth) of mpvar ! 1 if project p starts in month t, ! 0 otherwise start: array(RProj) of mpvar ! Start month for project i end-declarations ! Objective: maximise total profit Profit:= sum(p in RProj,t in 1..(NMonth-DUR(p))) BEN(p)* (NMonth-t-DUR(p)+1) * x(p,t) ! We have to do each project, but only once forall(p in RProj) OneX(p):= sum(t in RMonth) x(p,t) = 1.0 ! If a project starts at time t it is in its ! k-t+1 th month in month k forall(k in RMonth) ResMx(k):= sum(p in RProj,t in 1..k) PROF(p,k+1-t)*x(p,t)<= RES(k) ! The variables start(p) get the value of the start month for project p forall(p in RProj) SDefine(p):= sum(t in RMonth) t*x(p,t) = start(p) forall(p in RProj,t in RMonth) x(p,t) is_binary ! Solve the problem maximise(Profit) writeln("Solution: ", getobjval) write(" ") forall(t in RMonth) write(t) writeln forall(p in RProj) do write(p, ": ") forall(t in RMonth) write( if(t<getsol(start(p)), " ", if(t<getsol(start(p))+DUR(p), "*", "B")) ) writeln end-do end-model
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
© Copyright 2022 Fair Isaac Corporation. |