Initializing help system before first use

Blend: A model for mineral blending


Type: Blending
Rating: 1 (simple)
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 input from file
  • bounds on variables
File(s): blend.mos
Data file(s): blend.dat


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
 MINGRADE = 4                  ! Min permitted grade of product
 MAXGRADE = 5                  ! Max permitted grade 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

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

                               ! Lower and upper bounds on ore quality
 LoGrade:= sum(o in ROres) (GRADE(o)-MINGRADE) * x(o) >= 0
 UpGrade:= sum(o in ROres) (MAXGRADE-GRADE(o)) * x(o) >= 0 

                               ! 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)
 writeln("Grade: ", 
         (sum(o in ROres) GRADE(o)*x(o).sol) / sum(o in ROres) x(o).sol, 
         "  [min,max]: [", MINGRADE, ",", MAXGRADE, "]")

end-model

© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.