| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

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 tsp.mos (!********************************************************************* Mosel Example Problems ====================== file tsp.mos ```````````` Travelling salesman problem Example solution to exercise 7.1 in section 7.10 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 'tsp' uses "mmxprs" declarations N=8 NODES=1..N C: array(NODES,NODES) of real ! Distances d: array(NODES,NODES) of mpvar ! Selection of arcs travelled y: array(NODES) of mpvar ! Aux. subtour elimination variables end-declarations C::[1000,185,270,315,124,123,99,180, 185,1000,215,219,187,154,210,190, 270,215,1000,210,220,238,198,150, 315,219,210,1000,218,134,157,149, 124,187,220,218,1000,168,143,129, 123,154,238,134,168,1000,198,201, 99,210,198,157,143,198,1000,180, 180,190,150,149,129,201,180,1000] ! Objective: minimise total cost Cost:=sum(i in NODES,j in NODES|i<>j) C(i,j) * d(i,j) forall(j in NODES) C1(j):=sum(i in NODES|i<>j) d(i,j) = 1 ! Each city is entered forall(i in NODES) C2(i):=sum(j in NODES|i<>j) d(i,j) = 1 ! Each city left forall(i in 2..N,j in 2..N| i<>j) C3(i,j):=y(i) - y(j) + (N-1)*d(i,j) <= N-2 ! Exclude invalid tours forall(i in NODES,j in NODES|i<>j) d(i,j) is_binary ! Solve the problem minimise(Cost) writeln("Solution: Cost=", getobjval) firsti:=1 write(firsti) repeat nexti:=round(getsol(sum(j in NODES|firsti<>j) j*d(firsti,j))) write(" -> ",nexti) firsti:=nexti until nexti=1 writeln end-model | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

© Copyright 2023 Fair Isaac Corporation. |