« Previous « Start » Next »
25 Ground transport
25.1 Car rental
% function Result = carrentalEx(PriLev)
%
% Creates a TOMLAB MIP problem for car rental
%
% CAR RENTAL
%
% A small car rental company has a fleet of 94 vehicles distributed
% among its 10 agencies. The location of every agency is given by its
% geographical coordinates X and Y in a grid based on kilometers. We
% assume that the road distance between agencies is approximately 1.3
% times the Euclidean distance (as the crow flies). The following
% table indicates the coordinates of all agencies, the number of cars
% required the next morning, and the stock of cars in the evening
% preceding this day.
%
% Description of the vehicle rental agencies
%
% +-------------+--+--+--+--+--+--+--+--+--+--+
% |Agency | 1| 2| 3| 4| 5| 6| 7| 8| 9|10|
% +-------------+--+--+--+--+--+--+--+--+--+--+
% |X coordinate | 0|20|18|30|35|33| 5| 5|11| 2|
% |Y coordinate | 0|20|10|12| 0|25|27|10| 0|15|
% +-------------+--+--+--+--+--+--+--+--+--+--+
% |Required cars|10| 6| 8|11| 9| 7|15| 7| 9|12|
% |Cars present | 8|13| 4| 8|12| 2|14|11|15| 7|
% +-------------+--+--+--+--+--+--+--+--+--+--+
%
% Supposing the cost for transporting a car is $ 0.50 per km,
% determine the movements of cars that allow the company to
% re-establish the required numbers of cars at all agencies,
% minimizing the total cost incurred for transport.
%
% VARIABLES
%
% demand Required cars per agency
% stock Cars present
% cost Cost per km to transport a car
% xcord The X-coordinate of agencies
% ycord The Y-coordinate of agencies
% n Number of agencies
% distance A matrix of distances
%
% RESULTS
%
% For an interpretation of the results, try this:
% Result = carrentalEx(2);
%
% REFERENCES
%
% Applications of optimization... Gueret, Prins, Seveaux
% http://web.univ-ubs.fr/lester/~sevaux/pl/index.php
%
% INPUT PARAMETERS
% PriLev Print Level
%
% OUTPUT PARAMETERS
% Result Result structure.
% Marcus Edvall, Tomlab Optimization Inc, E-mail: tomlab@tomopt.com
% Copyright (c) 2005-2005 by Tomlab Optimization Inc., $Release: 5.0.0$
% Written Oct 19, 2005. Last modified Oct 19, 2005.
function Result = carrentalEx(PriLev)
if nargin < 1
PriLev = 1;
end
demand = [10 6 8 11 9 7 15 7 9 12]';
stock = [ 8 13 4 8 12 2 14 11 15 7]';
cost = 0.50;
xcord = [ 0 20 18 30 35 33 5 5 11 2]';
ycord = [ 0 20 10 12 0 25 27 10 0 15]';
n = length(xcord);
distance = zeros(n,n);
for i=1:n
for j=1:n
distance(i,j) = 1.3*sqrt( (xcord(i) - xcord(j))^2 + (ycord(i) - ycord(j))^2);
end
end
Prob = carrental(cost, distance, stock, demand);
Result = tomRun('cplex', Prob, PriLev);
if PriLev > 1,
idx_excess = find(stock-demand > 0);
idx_need = find(stock-demand < 0);
n_excess = length(idx_excess);
n_need = length(idx_need);
temp = reshape(Result.x_k,n_excess,n_need);
disp('THE SENDING OF CARS')
for i = 1:n_excess, % scan all positions, disp interpretation
disp(['agency ' num2str(idx_excess(i)) ' sends: ' ])
for j = 1:n_need,
if temp(i,j) ~= 0
disp([' ' num2str(temp(i,j)) ' car(s) to agency ' ...
num2str(idx_need(j))])
end
end
disp(' ')
end
disp('THE GETTING OF CARS')
for j = 1:n_need,
disp(['agency ' num2str(idx_need(j)) ' gets: ' ])
for i = 1:n_excess, % scan all positions, disp interpretation
if temp(i,j) ~= 0
disp([' ' num2str(temp(i,j)) ' car(s) from agency ' ...
num2str(idx_excess(i))])
end
end
disp(' ')
end
end
% MODIFICATION LOG
%
% 051019 med Created.
% 060112 per Added documentation.
% 060125 per Moved disp to end
25.2 Choosing the mode of transport
% function Result = choosingthemodeoftransportEx(PriLev)
%
% Creates a TOMLAB MIP problem for choosing the mode of transport
%
% CHOOSING THE MODE OF TRANSPORT
%
% A company in the south-west of France needs to transport 180 tonnes
% of chemical products stored in depots D1 to D4 to the three
% recycling centers C1, C2, and C3. The depots D1 to D4 contain
% respectively 50, 40, 35, and 65 tonnes, that is 190 tonnes in
% total. Two modes of transport are available: road and rail. Depot
% D1 only delivers to centers C1 and C2 and that by road at a cost of
% $ 12k/t and $ 11k/t. Depot D2 only delivers to C2, by rail or road
% at $ 12k/t and $ 14k/t respectively. Depot D3 delivers to center C2
% by road ($ 9k/t) and to C3 by rail or road for $ 4k/t and $ 5k/t
% respectively. The depot D4 delivers to center C2 by rail or road at
% a cost of $ 11k/t and $ 14k/t, and to C3 by rail or road at $ 10k/t
% and $ 14k/t respectively.
%
% Its contract with the railway company for the transport of chemical
% products requires the company to transport at least 10 tonnes and
% at most 50 tonnes for any single delivery. Besides the standard
% security regulations, there are no specific limitations that apply
% to road transport. How should the company transport the 180 tonnes
% of chemicals to minimize the total cost of transport?
%
% Graph of connections.
%
% ------ 7 (road) \
% +-- 2 (D1) / \
% / \ / 12 (C1)
% / \ / /
% / --+-- 6 (rail) / \
% | +- 3 (D2) | / \
% | / --+----/ \
% | / | \
% | / | \
% +----+---- 8 (rail) \ \
% 1 / \ \
% \ / \ 13 (C2) ----- 15
% | \ / \ /
% | \ \ 9 (road) / /
% | +-- 5 ------------ /
% | (D4) \ ------ /
% | \ / /
% \ +--+----- 10 (rail) \ /
% \ / / \ /
% \ ----+ / 14 (C3)
% +--- 4 ---------+ /
% (D3) \ 11 (road) /
% +-----------
%
%
% VARIABLES
%
% arcs_out/in For an arc i arcs_out(i) is its starting node
% and arcs_in(i) ts target node
% arcs_min Minimal load for an arc
% arcs_max Maximal load for an arc
% arcs_cost Cost for an arc
% minflow Flow from 1 to 15
%
% RESULTS
%
% For an interpretation of the results, try the following
% Result = choosingthemodeoftransportEx(2);
%
% REFERENCES
%
% Applications of optimization... Gueret, Prins, Seveaux
% http://web.univ-ubs.fr/lester/~sevaux/pl/index.php
%
% INPUT PARAMETERS
% PriLev Print Level
%
% OUTPUT PARAMETERS
% Result Result structure.
% Marcus Edvall, Tomlab Optimization Inc, E-mail: tomlab@tomopt.com
% Copyright (c) 2005-2005 by Tomlab Optimization Inc., $Release: 5.0.0$
% Written Oct 19, 2005. Last modified Oct 19, 2005.
function Result = choosingthemodeoftransportEx(PriLev)
if nargin < 1
PriLev = 1;
end
arcs_out = [ 1 1 1 1 2 2 3 3 4 4 4 5 5 5 5 ...
6 7 8 9 10 11 12 13 14 ]';
arcs_in = [ 2 3 4 5 7 9 6 7 9 10 11 8 9 10 11 ...
12 12 13 13 14 14 15 15 15 ]';
arcs_min = [zeros(1,6) 10 0 0 10 0 10 0 10 0 ...
zeros(1,9)]';
arcs_max = [50 30 35 65 inf inf 50 inf inf 50 inf 50 inf 50 inf ...
inf*ones(1,9)]';
arcs_cost = [0 0 0 0 12 11 12 14 9 4 5 11 14 10 14 ...
zeros(1,9) ]';
minflow = 50+30+35+65;
Prob = choosingthemodeoftransport(arcs_out, arcs_in, arcs_min, arcs_max, arcs_cost, minflow);
Result = tomRun('cplex', Prob, PriLev);
if PriLev > 1,
arcs = Result.x_k;
disp('transport as follows:')
for i = 1:length(arcs),
if arcs(i) ~= 0,
disp([' ' num2str(arcs(i)) ' units from node ' ...
num2str(arcs_out(i)) ' to node ' num2str(arcs_in(i))])
end
end
end
% MODIFICATION LOG
%
% 051019 med Created.
% 060112 per Added documentation.
% 060125 per Moved disp to end
25.3 Depot location
% function Result = depotlocationEx(PriLev)
%
% Creates a TOMLAB MIP problem for depot location
%
% DEPOT LOCATION
%
% A large company wishes to open new depots to deliver to its sales
% centers. Every new set-up of a depot has a fixed cost. Goods are
% delivered from a depot to the sales centers close to the site.
% Every delivery has a cost that depends on the distance covered. The
% two sorts of cost are quite different: set-up costs are capital
% costs which may usually be written off over several years, and
% transport costs are operating costs. A detailed discussion of how
% to combine these two costs is beyond the scope of this text — we
% assume here that they have been put on some comparable basis,
% perhaps by taking the costs over a year.
%
% There are 12 sites available for the construction of new depots and
% 12 sales centers need to receive deliveries from these depots.
%
% The following table gives the costs (in thousand $) of satisfying
% the entire demand of each customer (sales center) from a depot (not
% the unit costs). So, for instance, the cost per unit of supplying
% customer 9 (who has a total demand of 30 tonnes according to the
% next table) from depot 1 is $ 60000/30t, i.e. $ 2000/t. Certain
% deliveries that are impossible are marked with "Inf".
%
% Delivery costs for satisfying entire demand of customers
%
% +-----+-----------------------------------------------+
% | | Customer |
% |Depot| 1 2 3 4 5 6 7 8 9 10 11 12|
% +-----+---+---+---+---+---+---+---+---+---+---+---+---+
% | 1 |100| 80| 50| 50| 60|100|120| 90| 60| 70| 65|110|
% | 2 |120| 90| 60| 70| 65|110|140|110| 80| 80| 75|130|
% | 3 |140|110| 80| 80| 75|130|160|125|100|100| 80|150|
% | 4 |160|125|100|100| 80|150|190|150|130|Inf|Inf|Inf|
% | 5 |190|150|130|Inf|Inf|Inf|200|180|150|Inf|Inf|Inf|
% | 6 |200|180|150|Inf|Inf|Inf|100| 80| 50| 50| 60|100|
% | 7 |100| 80| 50| 50| 60|100|120| 90| 60| 70| 65|110|
% | 8 |120| 90| 60| 70| 65|110|140|110| 80| 80| 75|130|
% | 9 |140|110| 80| 80| 75|130|160|125|100|100| 80|150|
% | 10 |160|125|100|100| 80|150|190|150|130|Inf|Inf|Inf|
% | 11 |190|150|130|Inf|Inf|Inf|200|180|150|Inf|Inf|Inf|
% | 12 |200|180|150|Inf|Inf|Inf|100| 80| 50| 50| 60|100|
% +-----+---+---+---+---+---+---+---+---+---+---+---+---+
%
% In addition, for every depot we have the following information: the
% fixed cost for constructing the depot that needs to be included
% into the objective function and its capacity limit, all listed in
% the table below.
%
% Fix costs and capacity limits of the depot locations
%
%+------------+----+----+-----+----+----+----+----+----+----+-----+----+----+
%|Depot | 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12|
%+------------+----+----+-----+----+----+----+----+----+----+-----+----+----+
%|Cost (k$) |3500|9000|10000|4000|3000|9000|9000|3000|4000|10000|9000|3500|
%|Capacity (t)| 300| 250| 100| 180| 275| 300| 200| 220| 270| 250| 230| 180|
%+------------+----+----+-----+----+----+----+----+----+----+-----+----+----+
%
% The quantities demanded by the sales centers (customers), are
% summarized in the following table.
%
% Demand data
% +----------+---+--+--+---+---+---+--+--+--+---+--+---+
% |Customer | 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|11| 12|
% +----------+---+--+--+---+---+---+--+--+--+---+--+---+
% |Demand (t)|120|80|75|100|110|100|90|60|30|150|95|120|
% +----------+---+--+--+---+---+---+--+--+--+---+--+---+
%
% In every case, the demand of a customer needs to be satisfied but a
% sales center may be delivered to from several depots. Which depots
% should be opened to minimize the total cost of construction and of
% delivery, whilst satisfying all demands?
%
% VARIABLES
%
% delcosts Costs to deliver to centre from depot
% idxinf Impossible combination of centre/depot
% delcosts(idxinf) A large number < Inf
% buildcosts Costs to build a depot=
% capacity Capacities per potential depot
% demand The customers demand in tonnes
%
% RESULTS
%
% To interpret the results run this:
% Result = depotlocationEx(2);
%
% REFERENCES
%
% Applications of optimization... Gueret, Prins, Seveaux
% http://web.univ-ubs.fr/lester/~sevaux/pl/index.php
%
% INPUT PARAMETERS
% PriLev Print Level
%
% OUTPUT PARAMETERS
% Result Result structure.
% Marcus Edvall, Tomlab Optimization Inc, E-mail: tomlab@tomopt.com
% Copyright (c) 2005-2005 by Tomlab Optimization Inc., $Release: 5.0.0$
% Written Oct 19, 2005. Last modified Oct 19, 2005.
function Result = depotlocationEx(PriLev)
if nargin < 1
PriLev = 1;
end
delcosts = [ 100 80 50 50 60 100 120 90 60 70 65 110;...
120 90 60 70 65 110 140 110 80 80 75 130;...
140 110 80 80 75 130 160 125 100 100 80 150;...
160 125 100 100 80 150 190 150 130 inf inf inf;...
190 150 130 inf inf inf 200 180 150 inf inf inf;...
200 180 150 inf inf inf 100 80 50 50 60 100;...
100 80 50 50 60 100 120 90 60 70 65 110;...
120 90 60 70 65 110 140 110 80 80 75 130;...
140 110 80 80 75 130 160 125 100 100 80 150;...
160 125 100 100 80 150 190 150 130 inf inf inf;...
190 150 130 inf inf inf 200 180 150 inf inf inf;...
200 180 150 inf inf inf 100 80 50 50 60 100];
idxinf = find(delcosts == inf);
delcosts(idxinf) = 1e6;
buildcosts = [3500 9000 10000 4000 3000 9000 9000 3000 4000 10000 9000 3500]';
capacity = [ 300 250 100 180 275 300 200 220 270 250 230 180]';
demand = [ 120 80 75 100 110 100 90 60 30 150 95 120]';
Prob = depotlocation(delcosts, buildcosts, capacity, demand, idxinf);
Result = tomRun('cplex', Prob, PriLev);
if PriLev > 1,
c = length(demand); % number of customers
d = length(buildcosts); % number of possible depots
build = find(Result.x_k(1:d)'); % the depots to build
deliver = reshape(Result.x_k(d+1:c*d+d),c,d);
deliver = deliver(:,build);
deliver(find(deliver<0.001)) = 0;
disp(['minimal total cost = ' num2str(Result.f_k) ])
disp(['build the depots ' num2str(build) ])
[jj,ii] = size(deliver); % ii = depots, jj = customers
for j = 1:jj,
disp(['let customer ' num2str(j) ' get '])
for i = 1:ii,
if deliver(j,i) ~= 0,
if deliver(j,i) == 1,
disp([' all of its demand from depot ' num2str(build(i)) ])
else
disp([' ' num2str(deliver(j,i)) ...
' of its demand from depot ' num2str(build(i)) ])
end
end
end
end
end
% MODIFICATION LOG
%
% 051019 med Created.
% 060112 per Added documentation.
% 060125 per Moved disp to end
25.4 Heating oil delivery
% function Result = heatingoildeliveryEx(PriLev)
%
% Creates a TOMLAB MIP problem for heating oil delivery
%
% HEATING OIL DELIVERY
%
% A transporter has to deliver heating oil from the refinery at
% Donges to a certain number of clients in the west of France. His
% clients are located at Brain-sur-l’Authion, Craquefou, Guérande, la
% Haie Fouassière, Mésanger and les Ponts-de-Cé. The following table
% lists the demands in liters for the different sites.
%
% Demands by clients (in liters)
%
% +-----------+-----+-----+-----+-----+
% | BslA| Craq| Guér| H Fo| Mésa| P dC|
% +-----+-----+-----+-----+-----+-----+
% |14000| 3000| 6000|16000|15000| 5000|
% +-----+-----+-----+-----+-----+-----+
%
% The next table contains the distance matrix between the clients and
% the refinery.
%
% Distance matrix (in km)
% +-------------------+----+----+----+----+----+----+----+
% | |Dong|BslA|Craq|Guér|H Fo|Mésa|P dC|
% +-------------------+----+----+----+----+----+----+----+
% |Donges | 0| 148| 55| 32| 70| 140| 73|
% |Brain-s.-l’Authion | 148| 0| 93| 180| 99| 12| 72|
% |Craquefou | 55| 93| 0| 85| 20| 83| 28|
% |Guérande | 32| 80| 85| 0| 100| 174| 99|
% |Haie Fouassière | 70| 99| 20| 100| 0| 85| 49|
% |Mésanger | 140| 12| 83| 174| 85| 0| 73|
% |Ponts-de-Cé | 73| 72| 28| 99| 49| 73| 0|
% +-------------------+----+----+----+----+----+----+----+
%
% The transport company uses tankers with a capacity of 39000 liters
% for the deliveries. Determine the tours for delivering to all
% clients that minimize the total number of kilometers driven.
%
% VARIABLES
%
% distance The distance matrix
% demand Demand
% capacity Capacity of tanker
%
% RESULTS
%
% Run this for an interpretation of the results
% Result = heatingoildeliveryEx(2);
%
% REFERENCES
%
% Applications of optimization... Gueret, Prins, Seveaux
% http://web.univ-ubs.fr/lester/~sevaux/pl/index.php
%
% INPUT PARAMETERS
% PriLev Print Level
%
% OUTPUT PARAMETERS
% Result Result structure.
% Marcus Edvall, Tomlab Optimization Inc, E-mail: tomlab@tomopt.com
% Copyright (c) 2005-2005 by Tomlab Optimization Inc., $Release: 5.0.0$
% Written Oct 20, 2005. Last modified Oct 20, 2005.
function Result = heatingoildeliveryEx(PriLev)
if nargin < 1
PriLev = 1;
end
distance = [ 0 148 55 32 70 140 73;...
148 0 93 180 99 12 72;...
55 93 0 85 20 83 28;...
32 180 85 0 100 174 99;...
70 99 20 100 0 85 49;...
140 12 83 174 85 0 73;...
73 72 28 99 49 73 0];
demand = [14000;3000;6000;16000;15000;5000];
capacity = 39000;
Prob = heatingoildelivery(distance, demand, capacity);
Result = tomRun('cplex', Prob, PriLev);
if PriLev > 1,
s = 7; % number of sites
names = ['Dong'; 'BslA'; 'Craq'; 'Guér'; 'H Fo'; 'Mésa'; 'P dC'];
tour = reshape(Result.x_k(1:s*s),s,s); % extract tour
tour(find(tour<0.5)) = 0; % remove false zeros
first = find(tour(1,:)); % might be an array
disp(['min distance of ' num2str(Result.f_k) ' km by using'])
for init = 1:length(first), % there might be many first stops
this_tour = [names(1,:)]; % start in Dong
site = first(init);
this_tour = [this_tour ' -> ' names(site,:)]; % add city 2
loop_me = 1;
next = find(tour(site,:)); % what city is next?
if next == 1, % if we are going home:
loop_me = 0; % do not enter while-loop
this_tour = [this_tour ' -> ' names(1,:)]; % just add home and quit
disp(['Tour ' num2str(init) ': ' num2str(this_tour) ])
end
while loop_me == 1, % if more than one stop
this_tour = [this_tour ' -> ' names(next,:)];% add them one at a time
next = find(tour(next,:));
if next == 1, % when we are going home
loop_me = 0; % stop loop
this_tour = [this_tour ' -> ' names(1,:)]; % finish names and quit
disp([' tour ' num2str(init) ': ' num2str(this_tour) ])
end
end
end
end
% MODIFICATION LOG
%
% 051020 med Created.
% 060112 per Added documentation.
% 060125 per Moved disp to end
25.5 Combining different modes of transport
% function Result = combiningdiffmodesoftranspEx(PriLev)
%
% Creates a TOMLAB MIP problem for combining different modes of transport
%
% COMBINING DIFFERENT MODES OF TRANSPORT
%
% A load of 20 tonnes needs to be transported on a route passing
% through five cities, with a choice of three different modes of
% transport: rail, road, and air. In any of the three intermediate
% cities it is possible to change the mode of transport but the load
% uses a single mode of transport between two consecutive cities.
% The following table lists the cost of transport in $ per tonne
% between the pairs of cities.
%
% Transport costs with different modes
%
%
% Pairs of cities
% +----+---+---+---+---+
% | |1–2|2–3|3–4|4–5|
% +----+---+---+---+---+
% |Rail| 30| 25| 40| 60|
% |Road| 25| 40| 45| 50|
% |Air | 40| 20| 50| 45|
% +----+---+---+---+---+
%
% The next table summarizes the costs for changing the mode of
% transport in $ per tonne. The cost is independent of location.
%
%
% Cost for changing the mode of transport
%
% +---------+----+----+---+
% |from \ to|Rail|Road|Air|
% +---------+----+----+---+
% |Rail | 0 | 5 | 12|
% |Road | 8 | 0 | 10|
% |Air | 15 | 10 | 0|
% +---------+----+----+---+
%
% How should we organize the transport of the load at the least cost?
%
% VARIABLES
%
% transpcost Transport costs
% changecost Cost to change mode of transport
% demand Load to transport
%
% RESULTS
%
% For an interpretation of the results, try this:
% Result = combiningdiffmodesoftranspEx(2);
%
% REFERENCES
%
% Applications of optimization... Gueret, Prins, Seveaux
% http://web.univ-ubs.fr/lester/~sevaux/pl/index.php
%
% INPUT PARAMETERS
% PriLev Print Level
%
% OUTPUT PARAMETERS
% Result Result structure.
% Marcus Edvall, Tomlab Optimization Inc, E-mail: tomlab@tomopt.com
% Copyright (c) 2005-2005 by Tomlab Optimization Inc., $Release: 5.0.0$
% Written Oct 20, 2005. Last modified Oct 20, 2005.
function Result = combiningdiffmodesoftranspEx(PriLev)
if nargin < 1
PriLev = 1;
end
transpcost = [ 30 25 40 60 ;...
25 40 45 50 ;...
40 20 50 45];
changecost = [ 0 5 12;...
8 0 10;...
15 10 0];
demand = 30;
Prob = combiningdiffmodesoftransp(transpcost, changecost, demand);
Result = tomRun('cplex', Prob, PriLev);
if PriLev > 1,
modes = reshape(Result.x_k(1:3*4),3,4);
means = ['rail';'road';'air '];
disp(['the min cost (' num2str(Result.f_k) ') is found by,'])
for m = 1:size(modes,2),
disp([' going from town ' num2str(m) ' to town ' num2str(m+1) ...
' by ' means(find(modes(:,m)),:)])
end
end
% MODIFICATION LOG
%
% 051020 med Created.
% 060112 per Added documentation.
% 060125 per Moved disp to end
25.6 Fleet planning for vans
% function Result = fleetplanningforvansEx(PriLev)
%
% Creates a TOMLAB MIP problem for fleet planning for vans
%
% FLEET PLANNING FOR VANS
%
% A chain of department stores uses a fleet of vans rented from
% different rental agencies. For the next six months period it has
% forecast the following needs for vans (table below):
%
% Requirements for vans for six months
%
% +---+---+---+---+---+---+
% |Jan|Feb|Mar|Apr|May|Jun|
% +---+---+---+---+---+---+
% |430|410|440|390|425|450|
% +---+---+---+---+---+---+
%
% At the 1st January, the chain has 200 vans, for which the rental
% period terminates at the end of February.
%
% To satisfy its needs, the chain has a choice among three types of
% contracts that may start the first day of every month: 3-months
% contracts for a total cost of $1700 per van, 4-months contracts at
% $2200 per van, and 5-months contracts at $2600 per van. How many
% contracts of the different types need to be started every month in
% order to satisfy the company’s needs at the least cost and to have
% no remaining vans rented after the end of June?
%
% Running contracts in month 5 (May) .........
% : :
% +-------:-------:-------+
% | Rent34: : |
% +-------+-------:-------:-------+
% | Rent33 : :
% +---------------:-------:-------+
% | Rent43 : : |
% +-------+---------------:-------:-------+
% | Rent42 : :
% +-----------------------:-------:-------+
% | Rent52 : : |
% +-------+-----------------------:-------:-------+
% | Rent51 : :
% +-------------------------------:-------:
% . . . : : .
% Month Jan : Feb : Mar : Apr : May : Jun :
% :.......:.......:.......:.......: :.......:
% :.......:
%
%
% VARIABLES
%
% demand Demand of vans per month
% initialsupply Vans per month
% contractlength Contracts available
% contractcost Cost of contracts
%
% RESULTS
%
% To interpret the result, use PriLev > 1, for example:
% Result = fleetplanningforvansEx(2);
%
% REFERENCES
%
% Applications of optimization... Gueret, Prins, Seveaux
% http://web.univ-ubs.fr/lester/~sevaux/pl/index.php
%
% INPUT PARAMETERS
% PriLev Print Level
%
% OUTPUT PARAMETERS
% Result Result structure.
% Marcus Edvall, Tomlab Optimization Inc, E-mail: tomlab@tomopt.com
% Copyright (c) 2005-2005 by Tomlab Optimization Inc., $Release: 5.0.0$
% Written Oct 21, 2005. Last modified Oct 21, 2005.
function Result = fleetplanningforvansEx(PriLev)
if nargin < 1
PriLev = 1;
end
demand = [ 430; 410; 440; 390; 425; 450];
initialsupply = [ 200; 200; 0; 0; 0; 0];
contractlength = [ 3; 4; 5];
contractcost = [ 1700; 2200; 2600];
Prob = fleetplanningforvans(demand, initialsupply, contractlength, contractcost);
Result = tomRun('cplex', Prob, PriLev);
if PriLev > 1,
months = length(demand);
c = length(contractlength);
temp = reshape(Result.x_k,c,months);
disp(['minimal cost of ' num2str(Result.f_k) ' by '])
for m = 1:months,
if sum(temp(:,m)) > 0,
rent = find(temp(:,m));
disp([' renting ' num2str(temp(rent,m)) ' vans for ' ...
num2str(contractlength(rent)) ' months in month ' num2str(m)])
end
end
end
% MODIFICATION LOG
%
% 051021 med Created.
% 060112 per Added documentation.
% 060125 per Moved disp to end
« Previous « Start » Next »