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

Economics and finance

Description
Problem name and type, featuresDifficultyRelated examples
H‑1 Choice of loans *
calculation of net present value
H‑2 Publicity campaign *
forall-do
H‑3 Portfolio selection ** h7qportf.mos
sets of integers, second formulation with semi-continuous, parameters
H‑4 Financing an early retirement scheme **
inline if, selection with `|'
H‑5 Family budget **
formulation of monthly balance constraints including different payment frequencies; as, mod, inline if, selection with `|'
H‑6 Choice of expansion projects ** capbgt_graph.mos
experiment with solutions: solve LP problem explicitly, ``round'' some almost integer variable and re-solve
H‑7 Mean variance portfolio selection: Quadratic Programming problem *** folioqp_graph.mos
parameters, forall-do, min, max, loop over problem solving


Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 13: Economics and finance problems

mosel_app_8.zip[download all files]

Source Files

Data Files





h6expand.mos

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

   file h6expand.mos
   `````````````````
   Planning the expansion of a company
  
   A company aims to expand and has a series of candidate 
   projects for a planning horizon of five years. Every 
   project has an annual cost and expected benefit after 
   five years. The forecast annual costs of the projects 
   for the next five years as well as the available yearly 
   funds are known. Which project(s) should the company 
   choose now to maximize the total benefit after five years?
   
   A simple IP model with binary decision variables is 
   implemented. For each period, we ensure that the 
   annual cost of the project is at most the available 
   funds for the specific year. The problem solving is
   started repeatedly, initially solving only the root 
   LP relaxation.

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

model "H-6 Expansion"
 uses "mmxprs"

 forward procedure printsol

 declarations
  PROJECTS = 1..5                     ! Set of possible projects
  TIME = 1..5                         ! Planning period
  
  COST: array(PROJECTS,TIME) of real  ! Annual costs of projects
  CAP: array(TIME) of real            ! Annually available capital
  RET: array(PROJECTS) of real        ! Estimated profits
  DESCR: array(PROJECTS) of string    ! Description of projects
   
  choose: array(PROJECTS) of mpvar    ! 1 if project is chosen, 0 otherwise
 end-declarations

 initializations from 'h6expand.dat'
  COST CAP RET DESCR
 end-initializations

! Objective: Total profit
 Profit:= sum(p in PROJECTS) RET(p)*choose(p)
 
! Limit on capital availability
 forall(t in TIME) sum(p  in PROJECTS) COST(p,t)*choose(p) <= CAP(t)  

 forall(p in PROJECTS) choose(p) is_binary 
 
! Solve the problem
 maximize(XPRS_LIN, Profit)
 write("LP solution: ")
 printsol

 maximize(Profit)
 write("MIP solution: ")
 printsol
 
! Force acceptance of project 1 (='rounding' of an almost integer LP solution value)
 choose(1)=1 

 maximize(Profit)
 write("Forcing project 1 (", DESCR(1), "): ")
 printsol
 
!-----------------------------------------------------------------

! Solution printing
 procedure printsol
  writeln("Total profit: ", getobjval)
  forall(p in PROJECTS | getsol(choose(p))>0) 
   writeln(" ", DESCR(p), " (", getsol(choose(p)), ")")
 end-procedure
 
end-model

Back to examples browserPrevious exampleNext example