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, 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)

mosel_app_1.zip[download all files]

Source Files

Data Files





a6electr.mos

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

   file a6electr.mos
   `````````````````
   Production of electricity
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "A-6 Electricity production"
 uses "mmxprs"
 
 declarations
  NT = 7
  TIME = 1..NT                       ! Time periods
  TYPES = 1..4                       ! Power generator types

  LEN, DEM: array(TIME) of integer   ! Length and demand of time periods
  PMIN,PMAX: array(TYPES) of integer ! Min. & max output of a generator type
  CSTART: array(TYPES) of integer    ! Start-up cost of a generator
  CMIN: array(TYPES) of integer      ! Hourly cost of gen. at min. output
  CADD: array(TYPES) of real         ! Cost/hour/MW of prod. above min. level
  AVAIL: array(TYPES) of integer     ! Number of generators per type

  start: array(TYPES,TIME) of mpvar  ! No. of gen.s started in a period
  work: array(TYPES,TIME) of mpvar   ! No. of gen.s working during a period
  padd: array(TYPES,TIME) of mpvar   ! Production above min. output level
 end-declarations
 
 initializations from 'a6electr.dat'
  LEN DEM PMIN PMAX CSTART CMIN CADD AVAIL
 end-initializations 
 
! Objective function: total daily cost
 Cost:= sum(p in TYPES, t in TIME) (CSTART(p)*start(p,t) +
          LEN(t)*(CMIN(p)*work(p,t) + CADD(p)*padd(p,t))) 
                                   
! Number of generators started per period and per type
 forall(p in TYPES, t in TIME) 
  start(p,t) >= work(p,t) - if(t>1, work(p,t-1), work(p,NT))

! Limit on power production above minimum level
 forall(p in TYPES, t in TIME) padd(p,t) <= (PMAX(p)-PMIN(p))*work(p,t)

! Satisfy demands
 forall(t in TIME) sum(p in TYPES) (PMIN(p)*work(p,t) + padd(p,t)) >= DEM(t)

! Security reserve of 20%
 forall(t in TIME) sum(p in TYPES) PMAX(p)*work(p,t) >= 1.20*DEM(t)

! Limit number of available generators; numbers of generators are integer
 forall(p in TYPES, t in TIME) do
  work(p,t) <= AVAIL(p)
  work(p,t) is_integer
 end-do

! Solve the problem
 minimize(Cost)

! Solution printing
 writeln("Daily cost: ", getobjval)

 write(strfmt("Time period ",-20))
 ct:=0
 forall(t in TIME) do
  write(strfmt(ct,5), "-", strfmt(ct+LEN(t),2), "")
  ct+=LEN(t)
 end-do 

 forall(p in TYPES) do
  write("\nType ", p, strfmt(" No. working ",-14)); 
  forall(t in TIME) write(strfmt(getsol(work(p,t)),8))
  write("\n", strfmt("Total output ",20)); 
  forall(t in TIME) write(strfmt(getsol((PMIN(p)*work(p,t) + padd(p,t))),8))
  write("\n", strfmt("of which add.",20)); 
  forall(t in TIME) write(strfmt(getsol(padd(p,t)),8))
 end-do
 writeln

end-model

Back to examples browserPrevious exampleNext example