| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ground transport Description
Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 10: Ground transport
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
Data Files
e1carrent.mos (!****************************************************** Mosel Example Problems ====================== file e1carrent.mos `````````````````` Fleet management in car rental A rental company has 94 cars at 10 locations. Assume the distance between each location is 1.3 times the Euclidean distance. Given the transport cost per km, determine how many cars to move between locations so that morning demand is met while minimizing total cost. Here the data is checked to confirm there are the number of cars required, exiting if stock does not meet demand. Then the locations are sorted into 'NEED' or 'EXCESS' locations with 'if-then-elif' to determine start (source) and destination (sink) locations. To calculate distance, this problem introduces the function 'sqrt' and the exponential operator '^'. (c) 2008-2022 Fair Isaac Corporation author: S. Heipcke, Mar. 2002, rev. Mar. 2022 *******************************************************!) model "E-1 Car rental" uses "mmxprs" declarations AGENTS = 1..10 ! Car rental agencies REQ: array(AGENTS) of integer ! Required number of cars STOCK: array(AGENTS) of integer ! Number of cars in stock X,Y: array(AGENTS) of integer ! Coordinates of rental agencies COST: real ! Cost per km of moving a car NEED: set of integer ! Agencies needing more cars EXCESS: set of integer ! Agencies with too many cars end-declarations initializations from 'e1carrent.dat' REQ STOCK X Y COST end-initializations if sum(a in AGENTS) (STOCK(a)-REQ(a)) <> 0 then writeln("Problem is infeasible") exit(0) end-if ! Calculate sets of agencies with excess or deficit of cars forall(a in AGENTS) if STOCK(a) - REQ(a) < 0 then NEED += {a} elif STOCK(a) - REQ(a) > 0 then EXCESS += {a} end-if finalize(NEED); finalize(EXCESS) declarations DIST: array(EXCESS,NEED) of real ! Distance between agencies move: array(EXCESS,NEED) of mpvar ! Cars exchanged between agencies end-declarations ! Calculate distances between agencies forall(a in EXCESS,b in NEED) DIST(a,b):= 1.3*sqrt((X(a)-X(b))^2 + (Y(a)-Y(b))^2) ! Objective: total transport cost Cost:= sum(a in EXCESS,b in NEED) COST*DIST(a,b)*move(a,b) ! Agencies with excess availability forall(a in EXCESS) sum(b in NEED) move(a,b) = STOCK(a) - REQ(a) ! Agencies in need of cars forall(b in NEED) sum(a in EXCESS) move(a,b) = REQ(b) - STOCK(b) forall(a in EXCESS,b in NEED) move(a,b) is_integer ! Solve the problem minimize(Cost) ! Solution printing writeln("Total cost: ", getobjval) write(" ->") forall(b in NEED) write(strfmt(b,3)) writeln setparam("realfmt","%3g") forall(a in EXCESS) do write(a," ") forall(b in NEED) write(getsol(move(a,b))) writeln end-do end-model | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
© Copyright 2024 Fair Isaac Corporation. |