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





a3refine.mos

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

   file a3refine.mos
   `````````````````
   Refinery planning
 
   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. Monthly demand must be met while certain levels of 
   octane value, vapor pressure, volatility, and sulfur content are 
   enforced by law. The objective is to minimize crude and production cost.

   A much more involved linear programming blending problem
   with two production stages that are related in complicated ways.  
   The implementation has sparse data with string indices that are 
   initialized dynamically from the input data file. A new set 
   'ALLPRODS' is defined as the union of several other sets.

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

model "A-3 Refinery planning"
 uses "mmxprs"
 
 declarations
  CRUDES: set of string                   ! Set of crudes
  ALLPRODS: set of string                 ! Intermediate and final products
  FINAL: set of string                    ! Final products
  IDIST: set of string                    ! Products obtained by distillation
  IREF: set of string                     ! Products obtained by reforming
  ICRACK: set of string                   ! Products obtained by cracking
  IPETROL: set of string                  ! Interm. products for petrol
  IDIESEL: set of string                  ! Interm. products for diesel
  IHO={"hogasoil", "hocrknaphtha", "hocrkgasoil"}  
                                          ! Interm. products for heating oil
  DEM: array(FINAL) of real               ! Min. production
  COST: array(set of string) of real      ! Production costs
  AVAIL: array(CRUDES) of real            ! Crude availability
  OCT, VAP, VOL: array(IPETROL) of real   ! Octane, vapor pressure, and
                                          ! volatility values
  SULF: array(IDIESEL) of real            ! Sulfur contents
  DIST: array(CRUDES,IDIST) of real       ! Composition of crudes (in %)
  REF: array(IREF) of real                ! Results of reforming (in %)
  CRACK: array(ICRACK) of real            ! Results of cracking (in %)
 end-declarations

 initializations from 'a3refine.dat'
  DEM COST OCT VAP VOL SULF AVAIL DIST REF CRACK
 end-initializations

 ALLPRODS:= FINAL+IDIST+IREF+ICRACK+IPETROL+IHO+IDIESEL

 declarations
  use: array(CRUDES) of mpvar             ! Quantities used
  produce: array(ALLPRODS) of mpvar       ! Quantities produced
 end-declarations

! Objective function
 Cost:= sum(c in CRUDES) COST(c)*use(c) + sum(p in IDIST) COST(p)*produce(p)

! Relations intermediate products resulting of distillation - raw materials
 forall(p in IDIST) produce(p) <= sum(c in CRUDES) DIST(c,p)*use(c)

! Relations between intermediate products
! Reforming:
 forall(p in IREF) produce(p) <= REF(p)*produce("naphtha")
! Cracking:
 forall(p in ICRACK) produce(p) <= CRACK(p)*produce("residue") 
 produce("crknaphtha") = produce("petcrknaphtha") + 
                         produce("hocrknaphtha") + produce("dslcrknaphtha")
 produce("crkgasoil") = produce("hocrkgasoil") + produce("dslcrkgasoil")
! Desulfurization:
 produce("gasoil") = produce("hogasoil") + produce("dslgasoil")

! Relations final products - intermediate products
 produce("butane") = produce("distbutane") + produce("refbutane") - 
                     produce("petbutane")
 produce("petrol") = sum(p in IPETROL) produce(p)
 produce("diesel") = sum(p in IDIESEL) produce(p)
 produce("heating") = sum(p in IHO) produce(p)

! Properties of petrol
 sum(p in IPETROL) OCT(p)*produce(p) >= 94*produce("petrol")
 sum(p in IPETROL) VAP(p)*produce(p) <= 12.7*produce("petrol")
 sum(p in IPETROL) VOL(p)*produce(p) >= 17*produce("petrol")

! Limit on sulfur in diesel oil
 sum(p in IDIESEL) SULF(p)*produce(p) <= 0.05*produce("diesel")

! Crude availabilities
 forall(c in CRUDES) use(c) <= AVAIL(c)

! Production capacities
 produce("naphtha") <= 30000               ! Reformer
 produce("gasoil") <= 50000                ! Desulfurization
 produce("residue") <= 40000               ! Cracker

! Satisfy demands
 forall(p in FINAL) produce(p) >= DEM(p)

! Solve the problem
 minimize(Cost)

! Solution printing
 writeln("Production costs: ", strfmt(getobjval,10,2))
 forall(c in CRUDES) writeln(c, ": ", getsol(use(c)))
 forall(p in ALLPRODS) writeln(p, ": ", getsol(produce(p)))
 writeln("Petrol properties:")
 writeln(" octane: ", 
   getsol(sum(p in IPETROL) OCT(p)*produce(p))/ getsol(produce("petrol")),
   " vapor presure: ", 
   getsol(sum(p in IPETROL) VAP(p)*produce(p))/ getsol(produce("petrol")),
   " volatility: ", 
   getsol(sum(p in IPETROL) VOL(p)*produce(p))/ getsol(produce("petrol")))
 writeln("Sulfur in diesel oil: ", 
   getsol(sum(p in IDIESEL) SULF(p)*produce(p))/getsol(produce("diesel")) )

end-model 

Back to examples browserPrevious exampleNext example