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

Using the debugger and profiler

Description
The Mosel debugger and profiler may be used either through Xpress Workbench or from the Mosel command line. The model prime2.mos shows typical debugging and profiling command sequences. The model prime3.mos is a more efficient re-formulation of the same algorithm. The model runprime2d.mos shows a debugging command sequence for a submodel started from this model.
  • prime2.mos: Debugging and profiling commands
  • runprime2d.mos: Parallel debugging (requires prime2d.mos)
  • prime3.mos: Prime number algorithm for large limit values
Further explanation of this example: 'Mosel User Guide', Chapter 'Debugger and Profiler'

primedebug.zip[download all files]

Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
prime2.mos[download]
prime3.mos[download]
runprime2d.mos[download]
prime2d.mos[download]





prime2.mos

(!******************************************************
   Mosel User Guide Example Problems
   ================================= 

   file prime2.mos 
   ```````````````
   Working with sets.
   -- Debugging and profiling --
 
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, 2001, rev. Jul. 2014
*******************************************************!)

model Prime 

 parameters
  LIMIT=20000                   ! Search for prime numbers in 2..LIMIT
 end-parameters

 declarations
  SNumbers: set of integer      ! Set of numbers to be checked
  SPrime: set of integer        ! Set of prime numbers
 end-declarations

 SNumbers:={2..LIMIT} 
 
 writeln("Prime numbers between 2 and ", LIMIT, ":")

 n:=2
 repeat
   while (not(n in SNumbers)) n+=1
   SPrime += {n}                ! n is a prime number
   i:=n
   while (i<=LIMIT) do          ! Remove n and all its multiples
     SNumbers-= {i}
     i+=n
   end-do
 until SNumbers={}    
 
 writeln(SPrime)
 writeln(" (", getsize(SPrime), " prime numbers.)")
 
end-model

(!

Debugging
=========
Use the following command sequence in the Mosel command line:

mosel debug prime2.mos 'LIMIT=50'
break 31
bcond 1-1 getsize(SNumbers) < 10
cont
print n
display SNumbers
display SPrime
cont
quit


Profiling
=========
Use the following command in the Mosel command line:

mosel profile prime2.mos 'LIMIT=50'

Obtain information about memory usage:

mosel debug prime2.mos
info SPrime
lsmods
quit

!)

Back to examples browserPrevious exampleNext example