| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 goalprog.mos (!********************************************************************* Mosel Example Problems ====================== file goalprog.mos ````````````````` Lexicographic Goal Programming Example discussed in section 5.4.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 author: S. Heipcke, October 2020 (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 "goalprog" uses "mmxprs" public declarations GOALS=1..3 Goal: array(GOALS) of linctr ! Goal constraints GSense: array(GOALS) of string ! 'max' or 'min' GDevType: array(GOALS) of string ! 'A'=absolute or 'P'=percentage GDelta: array(GOALS) of real ! Max. allowed deviation x,y: mpvar ! Decision variables end-declarations !******** Problem statement ******** ! Specification of Goals Profit:= 5*x+ 2*y-20 Waste:= -3*x+15*y-48 Bonus:= 1.5*x+21*y-3.8 ! Constraint 42*x+13*y <= 100 !******** Configuration of Goals ******** Goal(1):=Profit; Goal(2):=Waste; Goal(3):=Bonus GSense:: (1..3)["max","min","max"] GDevType::(1..3)[ "P", "A", "P"] GDelta:: (1..3)[ 10, 4, 20] !******** Goal Programming algorithm ******** forall(g in GOALS) do ! Solve the problem if GSense(g)="max" then maximize(Goal(g)) else minimize(Goal(g)) end-if ! Display solution status if getprobstat=XPRS_OPT then res:= getobjval writeln("\nSolution for Goal ", g, ": ", res, " x=", x.sol, " y=", y.sol) writeln(" Profit=", Profit.sol, " Waste=", Waste.sol, " Bonus=", Bonus.sol) ! Turn current goal into a constraint for the next iteration if GSense(g)="max" then Z:= res - if(GDevType(g)="P", GDelta(g)/100*abs(res), GDelta(g)) writeln(" New constraint: Goal(", g, ")>=", Z) Goal(g):= Goal(g) >= Z else Z:= res + if(GDevType(g)="P", GDelta(g)/100*abs(res), GDelta(g)) writeln(" New constraint: Goal(", g, ")<=", Z) Goal(g):= Goal(g) <= Z end-if else ! Interrupt the loop if problem is not solvable for current goal writeln("No solution for Goal ", g) break end-if end-do end-model | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
© Copyright 2024 Fair Isaac Corporation. |