Initializing help system before first use

Firestns: A set-covering model for emergency service provision


Type: Set covering
Rating: 1 (simple)
Description: Minimize the total number of firestations that are required to service a set of towns within a specified permissible travel time.
  • simple LP problem
  • definition of Booleans
  • logical conditions in constraint definition
File(s): fstns.mos


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

model Firestns                    ! Start a new model

uses "mmxprs"                     ! Load the optimizer library

declarations
 RTown=1..6                       ! Range of towns
 TIMELIMIT=20                     ! Max. time allowed to reach any town

 TIME: array(RTown,RTown) of integer  ! Time taken between each pair of towns
 SERVE: array(RTown,RTown) of boolean ! true if time within limit, false 
                                      ! otherwise (default)

 openst: array(RTown) of mpvar    ! 1 if ambulance at town; 0 if not
end-declarations

 TIME:: [ 0,15,25,35,35,25,
         15, 0,30,40,25,15,
         25,30, 0,20,30,25,
         35,40,20, 0,20,30,
         35,25,35,20, 0,19,
         25,15,25,30,19, 0]

(! This sets SERVE(t,s) to true if the time between the two towns is 
   within the time limit. We can then use SERVE to define a set of 
   constraints (see below). It is as well possible not to use the array
   SERVE and move the test directly into the definition of the constraints. 
!)
 forall(t,s in RTown) 
   SERVE(t,s) := TIME(t,s) <= TIMELIMIT
   
                                  ! Objective: minimize number fire stations
 MinSta:= sum(s in RTown) openst(s)

                                  ! Serve each town t by an open station s
 forall(t in RTown) 
  Serve(t):= sum(s in RTown|SERVE(t,s)) openst(s) >= 1

                                  ! Variables are 0/1
 forall(s in RTown) openst(s) is_binary
   
 minimize(MinSta)                 ! Solve the MIP-problem

                                  ! Print out the solution
 writeln("Solution:\n Minimum number of firestations: ", getobjval)
 forall(s in RTown) write(" open(", s ,"): ", openst(s).sol)
 write("\n    ")
 forall(s in RTown) write(s, " ")
 writeln
 forall(t in RTown | openst(t).sol=1) do
   write(" ", t, ": ")
   forall(s in RTown) write(if(SERVE(t,s), "Y ", ". "))  
   writeln
 end-do
 

end-model

© 2001-2020 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.