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, featuresDifficulty
H‑1 Choice of loans *
calculation of net present value
H‑2 Publicity campaign *
forall-do
H‑3 Portfolio selection **
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 **
experiment with solutions: solve LP problem explicitly, ``round'' some almost integer variable and re-solve
H‑7 Mean variance portfolio selection: Quadratic Programming problem ***
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
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "H-6 Expansion"
 uses "mmxprs"

 forward procedure print_sol

 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: ")
 print_sol

 maximize(Profit)
 write("MIP solution: ")
 print_sol
 
! Force acceptance of project 1
 choose(1)=1 

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

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

Back to examples browserPrevious exampleNext example