| |||||||||||||||||
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.
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
prime3.mos (!****************************************************** Mosel User Guide Example Problems ================================= file prime3.mos ``````````````` Prime number algorithm for large values of LIMIT. (c) 2008 Fair Isaac Corporation author: S. Heipcke, 2006 *******************************************************!) model "Prime (array)" parameters LIMIT=20000 ! Search for prime numbers in 2..LIMIT end-parameters declarations INumbers = 2..LIMIT ! Set of numbers to be checked SNumbers: array(INumbers) of boolean SPrime: set of integer ! Set of prime numbers end-declarations writeln("Prime numbers between 2 and ", LIMIT, ":") n:=2 repeat SPrime += {n} ! n is a prime number i:=n while (i<=LIMIT) do ! Remove n and all its multiples SNumbers(i):= true i+=n end-do while (n <= LIMIT and SNumbers(n)) n+=1 until (n>LIMIT) writeln(SPrime) writeln(" (", getsize(SPrime), " prime numbers.)") end-model | |||||||||||||||||
© Copyright 2023 Fair Isaac Corporation. |