FICO Xpress Optimization Examples Repository
 FICO Optimization Community FICO Xpress Optimization Home

Blending ores

Description
Several ores are blended to a final product that must have a certain quality ('grade'). We wish to determine the quantity of every ore to be used in the blend with the objective to maximize the total profit (calculated as sales revenues - raw material cost).
• simple LP problem
• data in model or input from file
• bounds on variables
Further explanation of this example: 'Mosel User Guide', Section 2.2 'A blending example'; 'Applications of optimization with Xpress-MP', Section 2.7 'Blending constraints'. Similar problems: Section 6.1 'Production of alloys', Section 6.2 'Animal food production', Section 6.3 'Refinery'

Source Files

Data Files

blend.mos

```(!*******************************************************
* Mosel Example Problems                              *
* ======================                              *
*                                                     *
* file blend.mos                                      *
* ``````````````                                      *
* Example for the use of the Mosel language           *
* (Blending problem)                                  *
*                                                     *
* Reading data from file.                             *
*                                                     *
* (c) 2008 Fair Isaac Corporation                     *
*     author: S. Heipcke, 2001, rev. Feb. 2010        *
*******************************************************!)

model Blend                    ! Start a new model

uses "mmxprs"                  ! Load the optimizer library

declarations
ROres = 1..2                  ! Range of Ores
REV = 125                     ! Unit revenue of product
COST: array(ROres) of real    ! Unit cost of ores
AVAIL: array(ROres) of real   ! Availability of ores
GRADE: array(ROres) of real   ! Grade of ores (measured per unit of mass)

x: array(ROres) of mpvar      ! Quantities of ores used
end-declarations

initializations from 'Data/blend.dat'
COST
AVAIL
end-initializations
! Objective: maximize total profit
Profit:= sum(o in ROres) (REV-COST(o))* x(o)

! Lower and upper bounds on ore quality

! Set upper bounds on variables
forall(o in ROres) x(o) <= AVAIL(o)

maximize(Profit)              ! Solve the LP-problem

! Print out the solution
writeln("Solution:\n Objective: ", getobjval)
forall(o in ROres)  writeln(" x(" + o + "): ", x(o).sol)