FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Mining and process industries

Description
Problem name and type, featuresDifficultyRelated examples
A‑1 Production of alloys: Blending problem

formulation of blending constraints; data with numerical indices, solution printout, if-then, getsol
* blending_graph.mos
A‑2 Animal food production: Blending problem

formulation of blending constraints; data with string indices, as, formatted solution printout, use of getsol with linear expressions, strfmt
* a1alloy.mos
A‑3 Refinery : Blending problem

formulation of blending constraints; sparse data with string indices, dynamic initialization, union of sets
** a2food.mos
A‑4 Cane sugar production : Minimum cost flow (in a bipartite graph)

mo ceil, is_binary, formattext
* e2minflow.mos, mincostflow_graph.mos
A‑5 Opencast mining: Minimum cost flow

encoding of arcs, solving LP-relaxation only, array of set
** a4sugar.mos
A‑6 Production of electricity: Dispatch problem

inline if, is_integer, looping over optimization problem solving
**


Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 6: Mining and process industries (blending problems)

mosel_app_1.zip[download all files]

Source Files

Data Files





a1alloy.mos

(!******************************************************
   Mosel Example Problems
   ======================

   file a1alloy.mos
   ````````````````
   Production of alloys   
   
   An order of steel must be met with a range of carbon, 
   copper, and manganese grades. Given the raw materials in
   stock, the objective is to determine the composition of
   the steel that minimizes the production cost.
   
   Simple linear programming blending problem formulation includes 
   data with numerical indices and introduction of if-then statement 
   for solution printout.

   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Feb. 2002
*******************************************************!)

model "A-1 Production of Alloys"
 uses "mmxprs"
 
 declarations
  COMP = 1..3                    ! Components (chemical elements)
  RAW  = 1..7                    ! Raw materials (alloys)
  
  P: array(RAW,COMP) of real     ! Composition of raw materials (in percent)
  PMIN,PMAX: array(COMP) of real ! Min. & max. requirements for components
  AVAIL: array(RAW) of real      ! Raw material availabilities
  COST: array(RAW) of real       ! Raw material costs per tonne
  DEM: real                      ! Amount of steel to produce

  use: array(RAW) of mpvar       ! Quantity of raw mat. used
  produce: mpvar                 ! Quantity of steel produced
 end-declarations
 
 initializations from 'a1alloy.dat'
  P PMIN PMAX AVAIL COST DEM
 end-initializations

! Objective function
 Cost:= sum(r in RAW) COST(r)*use(r)

! Quantity of steel produced = sum of raw material used
 produce = sum(r in RAW) use(r)

! Guarantee min. and max. percentages of every chemical element
 forall(c in COMP) do
  sum(r in RAW) P(r,c)*use(r) >= PMIN(c)*produce
  sum(r in RAW) P(r,c)*use(r) <= PMAX(c)*produce
 end-do
 
! Use raw materials within their limit of availability
 forall(r in RAW) use(r) <= AVAIL(r)

! Satisfy the demand
 produce >= DEM

! Solve the problem
 minimize(Cost)

! Solution printing
 declarations
  NAMES: array(RAW) of string
 end-declarations
 
 initializations from 'a1alloy.dat'   ! Get the names of the alloys
  NAMES
 end-initializations

 writeln("Total cost: ", getobjval)
 writeln("Amount of steel produced: ", getsol(produce))
 writeln("Alloys used:")
 forall(r in RAW) 
  if(getsol(use(r))>0) then
   write(NAMES(r), ": ", getsol(use(r)),"  ")
  end-if  
 write("\nPercentages (C, Cu, Mn): ")   
 forall(c in COMP) 
  write( getsol(sum(r in RAW) P(r,c)*use(r))/getsol(produce), "%  ")
 writeln

end-model

Back to examples browserPrevious exampleNext example