# TOMLAB  
# REGISTER (TOMLAB)
# LOGIN  
# myTOMLAB
TOMLAB LOGO

« Previous « Start » Next »

21  Mining and Processing

21.1  Production of alloys

% function Result = productionofalloysEx(PriLev)
%
% Creates a TOMLAB LP problem for production design of alloys
%
% PRODUCTION OF ALLOYS
%
% The company Steel has received an order for 500 tonnes of steel to
% be used in shipbuilding. This steel must have the following
% characteristics (‘grades’).
%
% Characteristics of steel ordered
% +---------------+-------+-------+
% |Chemical       |Minimum|Maximum|
% |Element        |Grade  |Grade  |
% +---------------+-------+-------+
% |Carbon (C)     |  2.0  | 3.0   |
% |Copper (Cu)    |  0.4  | 0.6   |
% |Manganese (Mn) |  1.2  | 1.65  |
% +---------------+-------+-------+
%
% The company has seven different raw materials in stock that may be
% used for the production of this steel. The table below lists the
% grades, available amounts and prices for all raw materials.
%
% Raw material grades, availabilities, and prices
% +----------------+---+----+----+------------+----+
% |Raw material    |C %|Cu %|Mn %|Availability|Cost|
% +----------------+---+----+----+------------+----+
% |Iron alloy 1    |2.5| 0  |1.3 |     400    |200 |
% |Iron alloy 2    | 3 | 0  |0.8 |     300    |250 |
% |Iron alloy 3    | 0 | 0.3|0   |     600    |150 |
% |Copper alloy 1  | 0 | 90 |0   |     500    |220 |
% |Copper alloy 2  | 0 | 96 |4   |     200    |240 |
% |Aluminum alloy 1| 0 | 0.4|1.2 |     300    |200 |
% |Aluminum alloy 2| 0 | 0.6|0   |     250    |165 |
% +----------------+---+----+----+------------+----+
%
% The objective is to determine the composition of the steel that
% minimizes the production cost.
%
% VARIABLES
%
% compsize                   Amount of steel to produce
% mincomp                    Minimal contents of each component.
% maxcomp                    Maximal contents of each component.
% rawcompmat                 Contents of raw material.
% rawavail                   Amount available of raw material.
% rawcost                    Cost of raw material.
%
% RESULTS
%
% Result.x_k has the same length as there are raw material. In it we
% find how much of each component we should buy. For an
% interpretation of the results, use PriLev > 1, for example:
% Result = productionofalloysEx(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 7, 2005.   Last modified Oct 7, 2005.

function Result = productionofalloysEx(PriLev)

if nargin < 1
   PriLev = 1;
end

compsize   = 500;
mincomp    = [2;.4;1.2];
maxcomp    = [3;.6;1.65];
rawcompmat = [[2.5;  3;  0;  0;  0;  0;  0],...
      [  0;  0; .3; 90; 96; .4; .6],...
      [1.3; .8;  0;  0;  4;1.2;  0]];
rawavail   = [ 400;300;600;500;200;300;250];
rawcost    = [ 200;250;150;220;240;200;165];

Prob = productionofalloys(compsize, mincomp, maxcomp, rawcompmat, rawavail, rawcost);
Result = tomRun('cplex', Prob, PriLev);

if PriLev > 1,
   names = [ 'Iron 1' ; 'Iron 2' ; 'Iron 3' ; 'Copp 1' ; ...
         'Copp 2' ; 'Alum 1' ; 'Alum 2'];
   disp(['the optimal steel contains:'])
   for i = 1:length(Result.x_k),
      if Result.x_k(i) > 0,
         disp(['   ' num2str(Result.x_k(i)) ' tonnes of ' names(i,:) ])
      end
   end
end

% MODIFICATION LOG
%
% 051007 med   Created.
% 060110 per   Added documentation.
% 060125 per   Moved disp to end

21.2  Animal food Production

% function Result = animalfoodproductionEx(PriLev)
%
% Creates a TOMLAB LP problem for animal food production
%
% ANIMAL FOOD PRODUCTION
%
% The company CowFood produces food for farm animals that is sold in
% two forms: powder and granules. The raw materials used for the
% production of the food are: oat, maize and molasses. The raw
% materials (with the exception of molasses) first need to be ground,
% and then all raw materials that will form a product are blended. In
% the last step of the production process the product mix is either
% transformed to granules or sieved to obtain food in the form of
% powder.
%                   Molasses -+
%                             |
%                             V       +---> Granulating --> Granules
% Oat ----+                           |
%         +-> Grinding --> Blending --+
% Maize --+                           |
%                                     +---> Sieving ------> Powder
% Animal food production process
%
% Every food product needs to fulfill certain nutritional
% requirements. The percentages of proteins, lipids and fibers
% contained in the raw materials and the required percentages in the
% final products are listed in the table below.
%
% Contents of nutritional components in percent
%
% +-----------------+--------+-------+-----+
% |Raw material     |Proteins|Lipids |Fiber|
% +-----------------+--------+-------+-----+
% |Oat              | 13.6   |  7.1  | 7.0 |
% |Maize            |  4.1   |  2.4  | 3.7 |
% |Molasses         |  5.0   |  0.3  | 25  |
% |Required contents| >=9.5  |  >=2  | <=6 |
% +-----------------+--------+-------+-----+
%
% There are limits on the availability of raw materials. The table
% below displays the amount of raw material that is available every
% day and the respective prices.
%
% Raw material availabilities and prices
%
% +------------+----------------------+------------+
% |Raw material|Available amount in kg|Cost in $/kg|
% +------------+----------------------+------------+
% |Oat         | 11900                |   0.13     |
% |Maize       | 23500                |   0.17     |
% |Molasses    |   750                |   0.12     |
% +------------+----------------------+------------+
%
% The cost of the different production steps are given in the
% following table.
%
% Production costs in $/kg
%
% +--------+--------+-----------+-------+
% |Grinding|Blending|Granulating|Sieving|
% +--------+--------+-----------+-------+
% |  0.25  | 0.05   |    0.42   |  0.17 |
% +--------+--------+-----------+-------+
%
% With a daily demand of nine tonnes of granules and twelve tonnes of
% powder, which quantities of raw materials are required and how
% should they be blended to minimize the total cost?
%
% VARIABLES
%
% compsize                   Amount of different food to produce
% mincomp                    Minimal content of nutrients
% maxcomp                    Maximal content of nutrients
% rawcompmat                 Content of nutrients in raw sources
% rawavail                   Available raw sources
% rawcost                    Cost of raw material
% prodcostsraw               Cost to process raw material
% prodcostsprod              Cost to produce products
%
% RESULTS
%
% For an interpretation of the results, use PriLev > 1, for example:
% animalfoodproductionEx(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 7, 2005.   Last modified Oct 7, 2005.

function Result = animalfoodproductionEx(PriLev)

if nargin < 1
   PriLev = 1;
end

compsize    = [9000;12000];
mincomp     = [9.5;2;0];
maxcomp     = [100;100;6];
rawcompmat  = [[13.6;4.1;5],...
      [7.1;2.4;.3],...
      [7;3.7;25]];
rawavail     = [11900;23500;750];
rawcost      = [.13;.17;.12];
prodcostsraw   = [[.25;.05;0;0],...
      [.25;.05;0;0],...
      [0;.05;0;0]];
prodcostsprod  = [[0;0;.42;0],...
      [0;0;0;.17]];

% .25;.05;.42;.17
% grind, blend, gran, siev

Prob = animalfoodproduction(compsize, mincomp, maxcomp, rawcompmat,...
   rawavail, rawcost, prodcostsraw, prodcostsprod);
Result = tomRun('cplex', Prob, PriLev);

if PriLev > 1,
   raws  = length(rawavail);
   prods = length(compsize);

   for prod = 1:prods,
      disp(['produce ' num2str(Result.x_k(end-prods+prod)) ...
            ' of product ' num2str(prod) ','])
      disp('   and use the following ingredients:')

      for raw = 1:raws,
         disp(['   ' num2str(Result.x_k(raws*(prod-1) + raw)) ...
               ' units of ingredient ' num2str(raw) ])
      end
   end
end

% MODIFICATION LOG
%
% 051007 med   Created.
% 060110 per   Added documentation.
% 060125 per   Moved disp to end

21.3  Refinery

% function Result = refineryEx(PriLev)
%
% Creates a TOMLAB LP problem for refinery production
%
% REFINERY
%
% A refinery produces butane, petrol, diesel oil, and heating oil
% from two crudes. Four types of operations are necessary to obtain
% these products: separation, conversion, upgrading, and blending.
%
% The separation phase consists of distilling the raw product into,
% among others, butane, naphtha, gasoil, and a residue. The residue
% subsequently undergoes a conversion phase (catalytic cracking) to
% obtain lighter products. The different products that come out of
% the distillation are purified (desulfurization or sweetening) or
% upgraded by a reforming operation that augments their octane value.
% Finally, to obtain the products that will be sold, the refinery
% blends several of the intermediate products in order to fulfill the
% prescribed characteristics of the commercial products. The
% following drawing gives a simplified overview on the production
% processes in this refinery.
%
% After the distillation, crude 1 gives 3% butane, 15% naphtha, 40%
% gasoil, and 15% residue. Crude 2 results in 5% butane, 20% naphtha,
% 35% gasoil, and 10% residue. The reforming of the naphtha gives 15%
% butane and 85% of reformate (reformed naphtha). The catalytic
% cracking of the residue results in 40% of cracked naphtha and 35%
% of cracked gasoil (note that these percentages do not add up to
% 100% because the process also produces 15% of gas, 5% coke and
% another type of residue that are not taken into consideration in
% our example). The petrol is produced with three ingredients:
% reformed naphtha (reformate), butane, and cracked naphtha. The
% diesel oil is obtained by blending sweetened gasoil, cracked
% gasoil, and cracked naphtha. The heating oil may contain gasoil and
% cracked naphtha without any restrictions on their proportions.
%
%          Crudes
%           |
%           V
%          Distillation -----------------------+
%           |                                  |
%   +-------+--------+--------------+          |
%   |                |              |          |
%  Gasoil           Residue        Naphta      |
%   |                |              |          |
%   V                V              V          V
%  Desulf.       Cat. crack        Reform --> Butane
%   |             |      |          |          |
%  Sw.Gasoil  C.Naphta  C.Gasoil Reformate     |
%   |          |         |          |          V
%   |          |         |          |  To Petrol Blending and Butane
%   |          |         |          V
%   |          |         |        To Petrol Blending
%   |          |         V
%   |          |       To Heating Oil and Diesel Blending
%   |          V
%   |      To Petrol, Heating Oil and Diesel Blending
%   V
%  To Heating Oil and Diesel Blending
%
% Simplified representation of a refinery
%
%
% Certain conditions on the quality of the petrol and diesel oil are
% imposed by law. There are three important characteristics for
% petrol: the octane value, vapor pressure and volatility. The octane
% value is a measure of the anti-knock power in the motor. The vapor
% pressure is a measure of the risk of explosion during storage,
% especially with hot weather. The volatility is a measure for how
% easy the motor is started during cold weather. Finally, the
% maximum sulfur content of the diesel oil is imposed by
% antipollution specifications. The following table summarizes the
% required characteristics of the final products and the composition
% of the intermediate ones. Fields are left empty if no particular
% limit applies. We work with the assumption that all these
% characteristics blend linearly by weight (in reality, this is only
% true for the sulfur contents).
%
% Characteristics of intermediate and final products
%+--------------+------+---------+-------+-------+-------+------+------+
%|Characteristic|Butane|Reformate|Cracked|Cracked|Desulf |Petrol|Diesel|
%|              |      |         |naphtha|gasoil |gasoil |      | oil  |
%+--------------+------+---------+-------+-------+-------+------+------+
%|Octane value  |  120 |   100   | 74    |    -  |   -   |>=94  |  -   |
%|Vapor pressure|   60 |   2.6   |  4.1  |    -  |   -   |<=12.7|  -   |
%|Volatility    |  105 |   3     | 12    |    -  |   -   |>=17  |  -   |
%|Sulfur (in %) |    - |    -    |  0.12 |  0.76 | 0.03  |  -   |<=0.05|
%+--------------+------+---------+-------+-------+-------+------+------+
%
% In the next month the refinery needs to produce 20,000 tonnes of
% butane, 40,000 tonnes of petrol, 30,000 tonnes of diesel oil, and
% 42,000 tonnes of heating oil. 250,000 tonnes of crude 1 and 500,000
% tonnes of crude 2 are available. The monthly capacity of the
% reformer are 30,000 tonnes, for the desulfurization 40,000 tonnes
% and for the cracking 50,000 tonnes. The cost of processing is based
% on the use of fuel and catalysts for the different operations: the
% costs of distillation, reforming, desulfurization, and cracking are
% $ 2.10, $ 4.18, $ 2.04 and $ 0.60 per tonne respectively.
%
% VARIABLES
%
% demand                     Demand of each product
% supply                     Supply of crudes
% capacity                   Capacity of reformer, desulfer and cracker.
% costs                      Cost for each step.
% supplycomp                 Contents of crudes.
% numvbls                    Number of variables
% octane                     Octane in intermediates
% vappres                    Vapor Pressure in intermediates
% volatility                 Volatility of intermediates
% sulfur                     Sulfur in intermediates
% reformer                   Output of components from reformer
% cracker                    Output of components from cracker
% petrolspec_L               Lower bounds (contents in petrol)
% petrolspec_U               Upper bounds (contents in petrol)
% dieselspec_L               Lower bounds (contents in diesel)
% dieselspec_U               Upper bounds (contents in diesel)
%
% RESULTS
%
% x_k is a vector containing:
% 4 Final productS                butane, petrol, diesel, heating oil
% 3 Intermediates to Petrol       petbutane, reformerate, petcrknaphtha
% 3 Intermediates to Diesel       dslgasoil, dslcrknaphtha, dslcrkgasoil
% 3 Intermediates to Heating Oil  hogasoil, hocrknaphtha, hocrkgasoil
% 4 Intermediates from Distilling distbutane, naphtha, residue, gasoil
% 2 Intermediates from Reforming  refbutane, reformerate
% 2 Intermediates from Cracking   crknaphtha, crkgasoil
% 2 Crudes                        crude1, crude2
%
% 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-2006 by Tomlab Optimization Inc., $Release: 5.1.0$
% Written Oct 10, 2005.   Last modified Jan 4, 2006.

function Result = refineryEx(PriLev)

if nargin < 1
   PriLev = 1;
end

demand          = [20;40;30;42]*1000;
supply          = [250;500]*1000;
capacity        = [30;40;50]*1000;
costs           = [2.1;2.1;4.18;.6;2.04];
supplycomp      = [.03 .15 .15 .40; .05 .2 .1 .35];
numvbls         = 4+3+3+3+4+2+2+2;

octane          = [120; 100; 74];
vappres         = [60; 2.6; 4.1];
volatility      = [105; 3; 12];
sulfur          = [.03; .12; .76];

reformer        = [.15 .85]';
cracker         = [.40 .35]';

petrolspec_L    = [94; 17];
petrolspec_U    = [12.7];
dieselspec_L    = [-inf];
dieselspec_U    = [.05];

% PRODUCTS
% butane, petrol, diesel, heating        (FINAL PRODUCTS, 4) 4
% petbutane, reformerate, petcrknaphtha  (IPETROL, 3) 7
% dslgasoil, dslcrknaphtha, dslcrkgasoil (IDIESEL, 3) 10
% hogasoil, hocrknaphtha, hocrkgasoil    (IHO, 3) 13
% distbutane, naphtha, residue, gasoil   (IDIST, 4) 17
% refbutane, reformerate                 (IREF, 2) 19
% crknaphtha, crkgasoil                  (ICRACK, 2) 21
% crude1, crude2                         (CRUDES, 2) 23

Prob = refinery(demand, supply, capacity, costs, supplycomp, numvbls, octane,...
   vappres, volatility, sulfur, reformer, cracker, petrolspec_L, petrolspec_U, ...
   dieselspec_L, dieselspec_U);

Result = tomRun('cplex', Prob, PriLev);

if PriLev > 1,
   disp('4 Final products')
   disp(['   butane        - ' num2str(Result.x_k(1))])
   disp(['   petrol        - ' num2str(Result.x_k(2))])
   disp(['   diesel        - ' num2str(Result.x_k(3))])
   disp(['   heating oil   - ' num2str(Result.x_k(4))])
   disp('3 Intermediates to Petrol')
   disp(['   petbutane     - ' num2str(Result.x_k(5))])
   disp(['   reformerate   - ' num2str(Result.x_k(6))])
   disp(['   petcrknaphtha - ' num2str(Result.x_k(7))])
   disp('3 Intermediates to Diesel')
   disp(['   dslgasoil     - ' num2str(Result.x_k(8))])
   disp(['   dslcrknaphtha - ' num2str(Result.x_k(9))])
   disp(['   dslcrkgasoil  - ' num2str(Result.x_k(10))])
   disp('3 Intermediates to Heating Oil')
   disp(['   hogasoil      - ' num2str(Result.x_k(11))])
   disp(['   hocrknaphtha  - ' num2str(Result.x_k(12))])
   disp(['   hocrkgasoil   - ' num2str(Result.x_k(13))])
   disp('4 Intermediates from Distilling')
   disp(['   distbutane    - ' num2str(Result.x_k(14))])
   disp(['   naphtha       - ' num2str(Result.x_k(15))])
   disp(['   residue       - ' num2str(Result.x_k(16))])
   disp(['   gasoil        - ' num2str(Result.x_k(17))])
   disp('2 Intermediates from Reforming')
   disp(['   refbutane     - ' num2str(Result.x_k(18))])
   disp(['   reformerate   - ' num2str(Result.x_k(19))])
   disp('2 Intermediates from Cracking')
   disp(['   crknaphtha    - ' num2str(Result.x_k(20))])
   disp(['   crkgasoil     - ' num2str(Result.x_k(21))])
   disp('2 Crudes')
   disp(['   crude1        - ' num2str(Result.x_k(22))])
   disp(['   crude2        - ' num2str(Result.x_k(23))])
end

% MODIFICATION LOG
%
% 051007 med   Created
% 060104 med   Updated and corrected
% 060110 per   Added documentation.
% 060125 per   Moved disp to end

21.4  Cane sugar Production

% function Result = canesugarproductionEx(PriLev)
%
% Creates a TOMLAB LP problem for cane sugar production
%
% CANE SUGAR PRODUCTION
%
% PROBLEM
%
% The harvest of cane sugar in Australia is highly mechanized. The sugar
% cane is immediately transported to a sugar house in wagons that run on
% a network of small rail tracks. The sugar content of a wagon load
% depends on the field it has been harvested from and on the maturity of
% the sugar cane. Once harvested, the sugar content decreases rapidly
% through fermentation and the wagon load will entirely lose its value
% after a certain time. At this moment, eleven wagons all loaded with the
% same quantity have arrived at the sugar house. They have been examined
% to find out the hourly loss and the remaining life span (in hours) of
% every wagon, these data are summarized in the following table.
%
% Table: Properties of the lots of cane sugar
%
% Lot             1  2  3  4  5  6  7  8  9 10 11
% Loss (kg/h)    43 26 37 28 13 54 62 49 19 28 30
% Life span (h)   8  8  2  8  4  8  8  8  8  8  8
%
% Every lot may be processed by any of the three, fully equivalent
% production lines of the sugar house. The processing of a lot takes two
% hours. It must be finished at the latest at the end of the life span of
% the wagon load. The manager of the sugar house wishes to determine a
% production schedule for the currently available lots that minimizes the
% total loss of sugar.
%
% VARIABLES
%
% proclines                  the number of processing lines
% proctime                   time in hours to process a wagon
% loss                       loss of sugar in kg per hour
% lifespan                   how long the sugar in a wagon will last
%
% RESULTS
%
% For an interpretation of the results, set PriLev > 1, for example:
% Result = canesugarproductionEx(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 7, 2005.   Last modified Dec 8, 2005.

function Result = canesugarproductionEx(PriLev)

if nargin < 1
   PriLev = 1;
end

proclines   = [3];
proctime    = [2];
loss        = [43;26;37;28;13;54;62;49;19;28;30];
lifespan    = [8;8;2;8;4;8;8;8;8;8;8];

Prob = canesugarproduction(proclines, proctime, loss, lifespan);
Result = tomRun('cplex', Prob, PriLev);

if PriLev > 1,
   lots      = length(lifespan);
   timeslots = ceil(lots/proclines(1));  % even a fraction means work
   temp      = reshape(Result.x_k,lots,timeslots);

   disp(['To minimize loss (' num2str(Result.f_k) ') use this schema'])

   for time = 1:timeslots,
      disp(['at ' num2str((time-1)*proctime(1)+8) '.00:'])
      idx = find(temp(:,time));
      disp(['   process the lots ' num2str(idx') ])
   end
   disp(['at ' num2str((time)*proctime(1)+8) '.00:'])
   disp( '   harvesting completed')
end

% MODIFICATION LOG
%
% 051007 med   Created
% 051208 med   Lifespan factor wrong
% 060109 per   lifespan(9) changed to 8
% 060109 per   Added documentation.
% 060125 per   Moved disp to end

21.5  Opencast mining

% function Result = opencastminingEx(PriLev)
%
% Creates a TOMLAB MIP problem for open cast mining
%
% OPENCAST MINING
%
% PROBLEM
%
% An opencast uranium mine is being prospected. Based on the results of
% some test drillings the mine has been subdivided into exploitation units
% called blocks. The pit needs to be terraced to allow the trucks to drive
% down to its bottom. The uranium deposit extends from east to west. The
% pit is limited in the west by a village and in the east by a group of
% mountains. Taking into account these constraints, 18 blocks of 10,000
% tonnes on three levels have been identified (Figure 6.3). To extract a
% block, three blocks of the level above it need to be extracted: the
% block immediately on top of it, and also, due to the constraints on the
% slope, the blocks to the right and to the left.
%
%
%   Village                                 Mountains
%          +---+---+---+---+---+---+---+---+
% Level 1: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
%          +---+---+---+---+---+---+---+---+
% Level 2: |   | 9 | 10| 11| 12| 13| 14|   |
%          +---+---+---+---+---+---+---+---+
% Level 3: |   |   | 15| 16| 17| 18|   |   |
%          +---+---+---+---+---+---+---+---+
%
% For example: If we were to extract block 17 we also need to extract the
%              blocks 11, 12 and 13. And in order to extract these blocks
%              we also need to extract blocks 3, 4, 5, 6 and 7.
%
% It costs $ 100 per tonne to extract a block of level 1, $ 200 per
% tonne for a block of level 2, and $ 300 per tonne for a block of
% level 3, with the exception of the hatched blocks that are formed of a
% very hard rock rich in quartz and cost $ 1000 per ton. The only blocks
% that contain uranium are those displayed in a gray shade (1, 7, 10, 12,
% 17, 18). Their market value is 200, 300, 500, 200, 1000, and
% $ 1200/tonne respectively. Block 18, although rich in ore, is made of
% the same hard rock as the other hatched blocks. Which blocks should be
% extracted to maximize the total benefit?
%
% VARIABLES
%
% values                     The profit for extracting the blocks
% depends                    Block dependencies.
%
% RESULT
%
% The result will be a vector with binary variables, as many as we have
% blocks. A 1 means do extract, and a 0 means do not extract.
%
% 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 7, 2005.   Last modified Oct 7, 2005.

function Result = opencastminingEx(PriLev)

if nargin < 1
   PriLev = 1;
end

values      = [200-100;-100;-100;-100;-100;-100;300-100;-100;...
      -1000;500-200;-200;200-200;-200;-1000;-1000;-1000;...
      1000-300;1200-1000]*10000;
depends     = [-1 -1 -1  0  0  0  0  0  3  0  0  0  0  0  0  0  0  0;...
      0 -1 -1 -1  0  0  0  0  0  3  0  0  0  0  0  0  0  0;...
      0  0 -1 -1 -1  0  0  0  0  0  3  0  0  0  0  0  0  0;...
      0  0  0 -1 -1 -1  0  0  0  0  0  3  0  0  0  0  0  0;...
      0  0  0  0 -1 -1 -1  0  0  0  0  0  3  0  0  0  0  0;...
      0  0  0  0  0 -1 -1 -1  0  0  0  0  0  3  0  0  0  0;...
      0  0  0  0  0  0  0  0 -1 -1 -1  0  0  0  3  0  0  0;...
      0  0  0  0  0  0  0  0  0 -1 -1 -1  0  0  0  3  0  0;...
      0  0  0  0  0  0  0  0  0  0 -1 -1 -1  0  0  0  3  0;...
      0  0  0  0  0  0  0  0  0  0  0 -1 -1 -1  0  0  0  3];

Prob = opencastmining(values, depends);
Result = tomRun('cplex', Prob, PriLev);

if PriLev > 1,
   level1 = [];
   for i = 1 : 8,
      if Result.x_k(i) == 1,
         level1 = [level1 ' * '];
      else,
         level1 = [level1 ' - '];
      end
   end
   level2 = [ ' - '];
   for i = 9 : 14,
      if Result.x_k(i) == 1,
         level2 = [level2 ' * '];
      else,
         level2 = [level2 ' - '];
      end
   end
   level2 = [level2 ' - '];
   level3 = [ ' - ' ' - '];
   for i = 15 : 18,
      if Result.x_k(i) == 1,
         level3 = [level3 ' * '];
      else,
         level3 = [level3 ' - '];
      end
   end
   level3 = [level3 ' - ' ' - '];
disp(' ')
disp('Extraction profile')
disp(' ')
disp(['Level 1:  ' level1])
disp(['Level 2:  ' level2])
disp(['Level 3:  ' level3])
disp(' ')
disp('Legend: * means do extract')
disp('        - means do not extract')
end

% MODIFICATION LOG
%
% 051007 med   Created.
% 060109 per   Added documentation.
% 060125 per   Moved disp to end

21.6  Production of Electricity

% function Result = productionofelectricityEx(PriLev)
%
% Creates a TOMLAB MIP problem for production of electricity
%
% PRODUCTION OF ELECTRICITY
%
% Power generators of four different types are available to satisfy the
% daily electricity demands (in megawatts) summarized in the following
% table. We consider a sliding time horizon: the period 10pm-12am of day d
% is followed by the period 0am-6am of day d + 1.
%
% Daily electricity demands (in MW)
%
% +-------+-------+-------+--------+--------+-------+--------+---------+
% |Period |0am-6am|6am-9am|9am-12pm|12pm-2pm|2pm-6pm|6pm-10pm|10pm-12am|
% +-------+-------+-------+--------+--------+-------+--------+---------+
% |Demand |  12000|  32000|   25000|   36000|  25000|   30000|    18000|
% +-------+-------+-------+--------+--------+-------+--------+---------+
%
% The power generators of the same type have a maximum capacity and may be
% connected to the network starting from a certain minimal power output.
% They have a start-up cost, a fixed hourly cost for working at minimal
% power, and an hourly cost per additional megawatt for anything beyond
% the minimal output. These data are given in the following table.
%
% Description of power generators
% +---------+-----------+------+--------+--------+------------+--------+
% |Available|Min. output|Max.  |capacity|Fix cost|Add. MW cost|Start-up|
% |number   |in MW      |in MW |$/h     |        |$/h         |cost    |
% +---------+-----------+------+--------+--------+------------+--------+
% |Type 1   |  10       |  750 |  1750  |  2250  |  2.7       | 5000   |
% |Type 2   |   4       | 1000 |  1500  |  1800  |  2.2       | 1600   |
% |Type 3   |   8       | 1200 |  2000  |  3750  |  1.8       | 2400   |
% |Type 4   |   3       | 1800 |  3500  |  4800  |  3.8       | 1200   |
% +---------+-----------+------+--------+--------+------------+--------+
%
% A power generator can only be started or stopped at the beginning of a
% time period. As opposed to the start, stopping a power plant does not
% cost anything. At any moment, the working power generators must be able
% to cope with an increase by 20% of the demand forecast. Which power
% generators should be used in every period in order to minimize the total
% daily cost?
%
% VARIABLES
%
% demand                     MW needed each period
% available                  Generators of each type available
% mincap                     Minimal output of generator
% maxcap                     Maximal output of generator
% fixcost                    Fix cost per hour
% runningcost                Cost per hour and MW above mincap
% startcost                  Cost for starting a generator
% periodlengths              Hours in each period
%
% RESULTS
%
% For an interpretation of the results use PriLev > 1, for example:
% Result = productionofelectricityEx(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 10, 2005.   Last modified Oct 10, 2005.

function Result = productionofelectricityEx(PriLev)

if nargin < 1
   PriLev = 1;
end

demand      = [12;32;25;36;25;30;18]*1000;
available   = [10;4;8;3];
mincap      = [750;1000;1200;1800];
maxcap      = [1750;1500;2000;3500];
fixcost     = [2250;1800;3750;4800];
runningcost = [2.7;2.2;1.8;3.8];
startcost   = [5000;1600;2400;1200];
periodlengths = [6;3;3;2;4;4;2];
Prob = productionofelectricity(demand, available, mincap, maxcap,...
   fixcost, runningcost, startcost, periodlengths);
Result = tomRun('cplex', Prob, PriLev);

if PriLev > 1,
   temp      = reshape(Result.x_k,length(available(:)),length(demand(:)),3);
   intervals = ['00-06';'06-09';'09-12';'12-14';'14-18';'18-22';'22-24'];
   starts    = temp(:,:,1);
   running   = temp(:,:,2);
   extra     = temp(:,:,3);
   [reacs, times] = size(starts);
   for time = 1:times,
      disp([' At ' intervals(time,:) '...'])
      for reac = 1:reacs,
         if running(reac,time) > 0,
            disp([   '   there are ' num2str(running(reac,time))  ...
                     ' reactors of type ' num2str(reac) ' running' ])
            if starts(reac,time) > 0,
               disp(['      (we started ' num2str( starts(reac,time))...
                     ' additional reactors)'])
            end
            if extra(reac,time) > 0,
               disp(['      (we also produce ' num2str(  extra(reac,time))...
                     ' MW more than the minimal level)'])
            end
         end
      end
   end
end

% MODIFICATION LOG
%
% 051010 med   Created.
% 060109 per   Added documentation.
% 060125 per   Moved disp to end

« Previous « Start » Next »