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

Mining and process industries

Problem name and type, featuresDifficulty
A‑1 Production of alloys: Blending problem *
formulation of blending constraints; data with numerical indices, solution printout, if-then, getsol
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
A‑3 Refinery : Blending problem **
formulation of blending constraints; sparse data with string indices, dynamic initialization, dynamic arrays, finalize, create, union of sets
A‑4 Cane sugar production : Minimum cost flow (in a bipartite graph) *
ceil, is_binary
A‑5 Opencast mining: Minimum cost flow **
encoding of arcs, solving LP-relaxation only
A‑6 Production of electricity: Dispatch problem **
inline if, is_integer

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

Source Files

Data Files


   Mosel Example Problems

   file a3refine.mos
   Refinery planning
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Feb. 2002

model "A-3 Refinery planning"
 uses "mmxprs"
  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 %)

 initializations from 'a3refine.dat'

 finalize(FINAL); finalize(CRUDES); finalize(IPETROL); finalize(IDIESEL) 
 finalize(IDIST); finalize(IREF); finalize(ICRACK)

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

! 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("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

! 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")) )


Back to examples browserPrevious exampleNext example