<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5763920051047304998</id><updated>2026-09-29T03:09:29.729-07:00</updated><category term="model based testing"/><category term="modeling"/><category term="sample"/><category term="code coverage"/><category term="equivalence"/><category term="slicing"/><category term="BST"/><category term="combinatorics"/><category term="stochastic"/><category term="cloud"/><category term="container"/><category term="design changes"/><category term="equivalence class partitioning"/><category term="implicit"/><category term="invariant"/><category term="model based integration testing"/><category term="requirements"/><category term="scrum"/><category term="service"/><category term="state space"/><category term="test cases"/><category term="ASP.NET"/><category term="ETSI"/><category term="acceptance scenarios"/><category term="agile"/><category term="algorithm"/><category term="azure"/><category term="boundary value"/><category term="bugs"/><category term="conference"/><category term="dependencies"/><category term="discussions"/><category term="domain"/><category term="domain input partitioning"/><category term="explicit"/><category term="fault-injection"/><category term="finite"/><category term="flexibility"/><category term="graph"/><category term="growing"/><category term="infinite"/><category term="interface"/><category term="managed service"/><category term="model"/><category term="multi-dimensional"/><category term="multi-threaded"/><category term="negative"/><category term="pair wise"/><category term="paradigm"/><category term="positive"/><category term="random"/><category term="risk analysis"/><category term="sampling"/><category term="simulation"/><category term="synchronization"/><category term="t-wise"/><category term="traveling salesman"/><category term="Ferrari"/><category term="NP-hard"/><category term="SetContainer"/><category term="abstraction level"/><category term="abuse"/><category term="accepting condition"/><category term="automation"/><category term="barrier"/><category term="baseline"/><category term="binary seach tree"/><category term="cars"/><category term="change"/><category term="choice"/><category term="collateral code coverage"/><category term="combinatorial model"/><category term="complex type"/><category term="concurrent"/><category term="constraint"/><category term="containers"/><category term="coverage"/><category term="critical path"/><category term="cycle"/><category term="density"/><category term="double"/><category term="ease of debugging"/><category term="efficiency"/><category term="encapsulation"/><category term="encapsulation of state"/><category term="explore"/><category term="extension model"/><category term="fault codes"/><category term="feature"/><category term="flexible"/><category term="floating point"/><category term="fragile"/><category term="fuzzy model"/><category term="germany"/><category term="goat"/><category term="heat-map"/><category term="heuristic oracle"/><category term="immutable"/><category term="input"/><category term="instance based"/><category term="integer"/><category term="integration point"/><category term="introduction"/><category term="iterative"/><category term="late game"/><category term="legacy"/><category term="lets make a deal"/><category term="lifting"/><category term="magic rule"/><category term="maintainability"/><category term="merge"/><category term="merging"/><category term="mock"/><category term="monty hall"/><category term="october"/><category term="optimization"/><category term="parallel"/><category term="partitioning"/><category term="patent"/><category term="path"/><category term="perception of time"/><category term="performance test"/><category term="pragmatic"/><category term="probability"/><category term="ramifications"/><category term="regression"/><category term="regression test"/><category term="reliability"/><category term="rigourous"/><category term="risk profile"/><category term="scheduler"/><category term="school"/><category term="spec explorer"/><category term="state-query"/><category term="stochastic accumulator"/><category term="strategy"/><category term="string"/><category term="struct"/><category term="system"/><category term="targeted effort"/><category term="test of time"/><category term="test oracle"/><category term="theoretical"/><category term="thread pool"/><category term="time"/><category term="tools"/><category term="tour"/><category term="unstable"/><category term="user"/><category term="validation"/><category term="vendor"/><category term="weighing"/><title type='text'>Applied Model Based Testing - Experiences &amp;amp; Examples</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>42</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-1399025186458588149</id><published>2014-10-09T11:07:00.002-07:00</published><updated>2014-10-09T11:07:44.487-07:00</updated><title type='text'>PowerShell and arrays a deceptive combination</title><content type='html'>

&lt;br /&gt;
&lt;div style=&quot;direction: ltr;&quot;&gt;

&lt;div style=&quot;direction: ltr; margin-left: 0in; margin-top: 0in; width: 7.595in;&quot;&gt;

&lt;div style=&quot;direction: ltr; margin-left: 0in; margin-top: 0in; width: 7.595in;&quot;&gt;

&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
So I was
reading up on PowerShell arrays on this TechNet site:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&lt;a href=&quot;http://technet.microsoft.com/en-us/library/ee692797.aspx&quot;&gt;http://technet.microsoft.com/en-us/library/ee692797.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
It gives
a brief introduction to PowerShell arrays and illustrates how powerful they
are. However, arrays in PowerShell are a curious beast indeed and in some cases
they can deceive you, so I thought I&#39;d give some additional insights into it in
the hopes it may save you from struggling with them for too long.&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Let&#39;s
start with the basics. One thing you can do with arrays is concatenation:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a =
1,2,3&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a += 4&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Now $a is
1,2,3,4. Neat.&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
But wait
a minute… let&#39;s try changing this example a bit&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a =
CommandThatReturnsIntegers&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a += 4&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
If
CommandThatReturnsIntegers returns 1,2,3 then everything works as expected. But
what if it just returns 1?&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a = 1&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a += 4&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Now $a is
5… oops? What just happened? Well, in essence we expected an array from
CommandThatReturnsIntegers but instead it gave us an integer. Well, we could
fix it such that it always returns @(1) instead of 1, then we get:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a = @(1)&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a += 4&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Now $a is
1,4. But what if we don&#39;t control the output of CommandThatReturnsIntegers,
then we are out of luck with this approach…&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
An
alternative is to use the comma operator, like this:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a = 1&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a = $a,4&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a now is
1,4 as we would like it to be. &lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Let&#39;s try
that with a starting array&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a =
1,2,3&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a = $a,4&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Again,
when evaluated $a is 1,2,3,4 as expected. Everything looks fine right?&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Now try
this:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a.count&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
2? Wait a
minute it evaluated to 1,2,3,4 yet the number of elements in the array is 2?&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Let&#39;s see
what we find when we look under the hood..&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a | % {
&quot;$_&quot; }&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Here I&#39;m
telling PowerShell to produce a string representation of the content of every
element in the array. The output is:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
1 2 3&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
4&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
So, as
you may have guessed already underneath the hood $a is an array of arrays.&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
This is a
common source of trouble when piping inputs to other commands. We would expect
to evaluate the command on each element not each nested array.&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
As an
example we might want to sum the values using:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a |
measure -Sum&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
However,
this raises the exception:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;&quot;&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Input object
&quot;System.Object[]&quot; is not numeric.&lt;/span&gt;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
But then
why does $a evaluate to 1,2,3,4 when we first looked at it? The reason is that
PowerShell is invoking black magic to unroll the nested array on our behalf
when we evaluate it!&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
That&#39;s
pretty bad and causes much deception in PowerShell-land. But there&#39;s a plus
side to this, we can leverage (abuse?) PowerShell&#39;s black magic to unroll the
array for us, using the following syntax:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$b = $a |
% { $_ }&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Now $b is
a truly flattened array. We can test this using:&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
$a | % {
$_ } | measure -Sum&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
Which now
gives us the expected value of 10.&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
The
benefit of this syntax is that it will work regardless of $a is a single
element, an array or a nested array.&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div lang=&quot;en-US&quot; style=&quot;font-family: Calibri; font-size: 11pt; margin: 0in;&quot;&gt;
In
conclusion when working with arrays take care and try to understand what goes
on underneath the hood. If you end up in a situation where the array is not
behaving as expected, do not rely on evaluating it in PowerShell to inspect
it&#39;s structure. Instead, use $a | % { &quot;$_&quot; } to see what it actually
holds. In case you are working with arrays and concatenation, make sure to
build your command robust by unrolling the input arrays using $a | % { $_ }.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/1399025186458588149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2014/10/powershell-and-arrays-deceptive.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/1399025186458588149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/1399025186458588149'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2014/10/powershell-and-arrays-deceptive.html' title='PowerShell and arrays a deceptive combination'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-3001490698654177220</id><published>2013-11-01T01:54:00.002-07:00</published><updated>2013-11-01T01:54:43.890-07:00</updated><title type='text'>Upgrading Windows Azure Service projects to Visual Studio 2013 does not work out-of-the-box</title><content type='html'>

&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This
morning I decided to upgrade my cloud service project from Visual Studio 2012
to 2013. The upgrade requires installing the Windows Azure SDK 2.2, and then do
an automatic upgrade of the project.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;On the
surface everything looked fine!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;However,
when I started deploying the upgraded service to Azure, the deployment never
completed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Having
spent quite some time trying different things with the Azure deployment, I
decided to try a local deployment in the emulator. I was expecting everything
to work fine, but I found out that my worker role just kept on recycling in the
emulator! It would call OnStart(), then Run() followed by a message that Run()
completed which triggers a role restart.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The next
logical step was to debug what was going on in the service, so I added
breakpoints to OnStart and Run, and to my surprise the debugger never kicked in…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;By then I
concluded that something was completely broken. Next up, I tried creating a new
service from the Visual Studio templates, which worked and debugging also
worked.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;After
comparing the project files, I finally figured out that Visual Studio 2013
upgrade had failed to upgrade the version of the Azure references!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I had to
update the csproj file and manually change the version number on the following references&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: currentColor; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;
 &lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: 0;&quot;&gt;
  &lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Assembly&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;From&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.5pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 1;&quot;&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Microsoft.ServiceBus&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.1.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.5pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.2.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2;&quot;&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Microsoft.WindowsAzure.Diagnostics&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.1.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.5pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.2.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 3;&quot;&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Microsoft.WindowsAzure.ServiceRuntime&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.1.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.5pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.2.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 4; mso-yfti-lastrow: yes;&quot;&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Microsoft.WindowsAzure.Storage&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.45pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.0.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 160.5pt;&quot; valign=&quot;top&quot; width=&quot;214&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: Consolas; mso-highlight: white;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.1.0.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;After that
I also had to update the same version numbers in the App.config file of the
service and everything was working again.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/3001490698654177220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2013/11/upgrading-windows-azure-service.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/3001490698654177220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/3001490698654177220'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2013/11/upgrading-windows-azure-service.html' title='Upgrading Windows Azure Service projects to Visual Studio 2013 does not work out-of-the-box'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-5075020638720444343</id><published>2013-09-02T05:13:00.001-07:00</published><updated>2013-09-02T05:14:17.810-07:00</updated><title type='text'>Large Scale Machine Learning powered by Windows Azure HDInsight</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In this article
I’m going to show how to setup a machine learning algorithm to classify documents
using a Big Data analytics cluster running in Windows Azure (HDInsight).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Azure HDInsight is
an easy and flexible way to provision an analytics cluster in the cloud for
doing Big Data analysis. A cluster consists of 1 main node, 1 job tracker node
and any number of compute nodes (workers), that are doing the heavy lifting. The
cluster is backed by the Open Source Big Data platform called &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://hadoop.apache.org/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Hadoop&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;. Hadoop is written in Java and it is an extensible
open platform for analyzing large sets of data in a fast and resilient fashion.
It’s built on top of Hadoop Distributed File System (HDFS) which is a
distributed file system similar to Google’s GFS and the so-called Map-Reduce
algorithm which distributes (map) work among any number of cluster nodes and
collects (reduce) the result to a single output (usually stored in HDFS).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;a href=&quot;http://mahout.apache.org/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Mahout&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; is an extension library built on top of Hadoop which enables
Machine Learning algorithms to run in the cluster.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I’m assuming you
have a Windows Azure subscription, if not it is possible to get free access to
Azure with your MSDN subscription, which you should be able to obtain if you
are a student or you can get a 1-month free trial &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://www.windowsazure.com/en-us/pricing/free-trial/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;here&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Setting up the Windows
Azure HDInsight cluster&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;As of August 2013
you need to sign up for the preview features of Azure as HDInsight is not part
of the standard Azure package, this may change in the near future when
HDInsight is completed. The steps to do so are outlined &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://www.windowsazure.com/en-us/manage/services/hdinsight/get-started-hdinsight/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;here&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, but I’ll repeat
them:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l2 level1 lfo2; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Symbol; mso-ansi-language: EN-US; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: DA;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Try to create an HDInsight data service in the Windows
Azure Management Portal, it will be grayed out and instead you should see a
link to ‘preview features’. Follow that link and sign up for HDInsight.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;After you sign up
and get a completed notification, you are ready to provision an HDInsight
cluster, but first we need to setup a dedicated storage account (which is &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;not&lt;/i&gt; geo-replicated)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraph&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l2 level1 lfo2; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Symbol; mso-ansi-language: EN-US; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: DA;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Create a new storage account, making sure to uncheck
the georeplicated box&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now we provision
our cluster&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l2 level1 lfo2; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Symbol; mso-ansi-language: EN-US; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: DA;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Make a new provisioning and select HDInsight cluster
under the data services category&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l2 level1 lfo2; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Symbol; mso-ansi-language: EN-US; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: DA;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Pick the storage account you created in the previous
step&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l2 level1 lfo2; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Symbol; mso-ansi-language: EN-US; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: DA;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Select a size for the cluster (small will do just
fine) and a strong password&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l2 level1 lfo2; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; font-family: Symbol; mso-ansi-language: EN-US; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: DA;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Click create&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A note here: I’ve
encountered an error when trying this step, where it fails on the second
operation. I just wait a couple of minutes and retry and things work out fine.
I think this is because I’m too fast after enabling the preview feature to the
time I provision the cluster, but I’m not certain.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Logging onto the
cluster&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;After the cluster
is created you can find it in its own category in the Windows Azure Management
Portal under HDInsight. Select your cluster and click ‘Manage Cluster’ this
will bring you into an HDInsight specific portal which will look something like
this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri; mso-no-proof: yes;&quot;&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype
 id=&quot;_x0000_t75&quot; coordsize=&quot;21600,21600&quot; o:spt=&quot;75&quot; o:preferrelative=&quot;t&quot;
 path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; filled=&quot;f&quot; stroked=&quot;f&quot;&gt;
 &lt;v:stroke joinstyle=&quot;miter&quot;/&gt;
 &lt;v:formulas&gt;
  &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;/&gt;
  &lt;v:f eqn=&quot;sum @0 1 0&quot;/&gt;
  &lt;v:f eqn=&quot;sum 0 0 @1&quot;/&gt;
  &lt;v:f eqn=&quot;prod @2 1 2&quot;/&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;/&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;/&gt;
  &lt;v:f eqn=&quot;sum @0 0 1&quot;/&gt;
  &lt;v:f eqn=&quot;prod @6 1 2&quot;/&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;/&gt;
  &lt;v:f eqn=&quot;sum @8 21600 0&quot;/&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;/&gt;
  &lt;v:f eqn=&quot;sum @10 21600 0&quot;/&gt;
 &lt;/v:formulas&gt;
 &lt;v:path o:extrusionok=&quot;f&quot; gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot;/&gt;
 &lt;o:lock v:ext=&quot;edit&quot; aspectratio=&quot;t&quot;/&gt;
&lt;/v:shapetype&gt;&lt;v:shape id=&quot;Picture_x0020_4&quot; o:spid=&quot;_x0000_i1028&quot; type=&quot;#_x0000_t75&quot;
 style=&#39;width:482.25pt;height:263.25pt;visibility:visible;mso-wrap-style:square&#39;&gt;
 &lt;v:imagedata src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot;
  o:title=&quot;&quot;/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmjC_lJAwvZOXPNtYNglBVkzr7Rb6WnSHuXr2CBz-_fd5RZxThsWgSU5YBySPAEOMWMVJFzKFtjRv2-eTJittJVwZU7fCmAOu61jD_NcnEcxsgWt0QB2GsthUu0h8T8BHN9EnsNwCgVWd/s1600/azure-hdinsight.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmjC_lJAwvZOXPNtYNglBVkzr7Rb6WnSHuXr2CBz-_fd5RZxThsWgSU5YBySPAEOMWMVJFzKFtjRv2-eTJittJVwZU7fCmAOu61jD_NcnEcxsgWt0QB2GsthUu0h8T8BHN9EnsNwCgVWd/s640/azure-hdinsight.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Click the ‘Remote
Desktop’ tile which will open an *.rdp file to connect to your main node.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Running Hadoop command&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Once you log onto
the main cluster node you should find a shortcut on the desktop by the name
‘Hadoop Command Line’. Click it to start a Hadoop prompt, which will show you
some high level help:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri; mso-no-proof: yes;&quot;&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape
 id=&quot;Picture_x0020_5&quot; o:spid=&quot;_x0000_i1027&quot; type=&quot;#_x0000_t75&quot; style=&#39;width:481.5pt;
 height:237pt;visibility:visible;mso-wrap-style:square&#39;&gt;
 &lt;v:imagedata src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png&quot;
  o:title=&quot;&quot;/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4Aaa55VYv09gLrrbGO_BJtNWf6RCedbKHigEj-HzoCyVbpYY9BgOKLTYNg0WMjU87S7bGNVepIh0HMU1LGe4kgFxtXgYONKoBW-5A5D3uPwM2GvikCWatXEdmdoQDaGgUgSce_-Z3bVP2/s1600/hadoop-cmdline.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;313&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4Aaa55VYv09gLrrbGO_BJtNWf6RCedbKHigEj-HzoCyVbpYY9BgOKLTYNg0WMjU87S7bGNVepIh0HMU1LGe4kgFxtXgYONKoBW-5A5D3uPwM2GvikCWatXEdmdoQDaGgUgSce_-Z3bVP2/s640/hadoop-cmdline.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Hadoop is the
engine behind our machine learning example, so it makes sense to explore it a
bit, however, I won’t go into details with it because my knowledge is limited
at this point.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The fundamental
functionality of Hadoop has to do with interacting with the file system. Keep
in mind that in the cluster you have a completely separate file system (HDFS)
which is not visible to Windows (it’s backed by the storage account you created
before provisioning the cluster). Hadoop exposes functionality to work with the
HDFS file system, you get to them using:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Hadoop fs
-&amp;lt;command&amp;gt; &amp;lt;args&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;File system
commands have Unix names (like ls, rm, cat, etc). So to upload a file from the
local disk to HDFS, you simply execute:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Hadoop fs –put
hdfs_folder/hdfs_file local_folder\local_file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This will upload a
local file (or folder) to HDFS and the data is now immediately available to the
compute nodes. For more info about file system commands check the &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://hadoop.apache.org/docs/r0.18.3/hdfs_shell.html&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;documentation&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice: The path
formats differ between local path and HDFS path. The HDFS format is Unix while
the local file system is of course Windows path format.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Another thing to
keep in mind is that for performance reasons the HDFS file system is immutable,
that means once data is placed on the file system you cannot edit it. If you
did something wrong, you would need to delete the files and then recreate them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The last thing we
need to know about Hadoop is that you run command using the ‘jar’ command,
which runs functionality exposed by Java packages in Hadoop. One example could
be to run a word counting job to count occurrences of words in a text file.
Create a new test file named mytextfile.txt and type something into it, then
run the following steps:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Hadoop fs –put
mytextfile.txt test/input.txt&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; text-indent: 65.2pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Hadoop jar hadoop-examples.jar wordcount
test/input.txt output&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; text-indent: 65.2pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Hadoop fs –cat output/*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This will create a
job that runs in the cluster, scanning the ‘mytextfile.txt’ for all words and
returns a list of words and their respective number of occurrences in the file.
In my case the input and output looks like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri; mso-no-proof: yes;&quot;&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape
 id=&quot;Picture_x0020_7&quot; o:spid=&quot;_x0000_i1026&quot; type=&quot;#_x0000_t75&quot; style=&#39;width:481.5pt;
 height:239.25pt;visibility:visible;mso-wrap-style:square&#39;&gt;
 &lt;v:imagedata src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image004.png&quot;
  o:title=&quot;&quot;/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb1hK6q8dZ5O_W8pobSvqwEaxZmcnVEQPJqiRtVswX1kL3YlHml_2yNeX6-g2HYbXDY-6mJ59khoWs2a6dbcppCrXJBMT2LyvdpqGUZ6vNMLE9PCnCgMNHdDxgLWiHpcRxZGOEcG8GSn9v/s1600/hadoop-output.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;316&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb1hK6q8dZ5O_W8pobSvqwEaxZmcnVEQPJqiRtVswX1kL3YlHml_2yNeX6-g2HYbXDY-6mJ59khoWs2a6dbcppCrXJBMT2LyvdpqGUZ6vNMLE9PCnCgMNHdDxgLWiHpcRxZGOEcG8GSn9v/s640/hadoop-output.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The way to
interpret the output is that the word ‘a’ occurred once, ‘hello’ occurred
twice, etc. The output of this command is a perfect example of a ‘vector’ where
each word is a dimension in the vector and the occurrence count is the value in
that dimension of the vector. As we shall see later, vectors are a recurring
theme in Hadoop – large data sets are almost always represented as vectors and
matrices.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is of course
a trivial example and it is complete overkill to use a data analytics cluster
to run this job. However, the same principles apply to Big Data analysis it
just takes a lot longer, and that’s why it’s nice to have a cluster helping you
out.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Machine Learning
in Azure&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Time to move on to
Machine Learning! The first step is to install Mahout onto the cluster. Go &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://www.apache.org/dyn/closer.cgi/mahout/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;here&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, then choose the
closest mirror to you and open the folder 0.8. You should see the following&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSj-Ijb7-QyoZWAYcO7hvDqQsmvc211sUPkSCk_67Z_-sDK8ZmYfWs-QArUWrn4bWTF5c_QwS6_TOBx2uN_SRLKXqpepRIFrrY2abM3Dx3G2ENnOQT8tW7aPVgs5vWiRnBFQVQDkiDjkF_/s1600/download-mahout.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;224&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSj-Ijb7-QyoZWAYcO7hvDqQsmvc211sUPkSCk_67Z_-sDK8ZmYfWs-QArUWrn4bWTF5c_QwS6_TOBx2uN_SRLKXqpepRIFrrY2abM3Dx3G2ENnOQT8tW7aPVgs5vWiRnBFQVQDkiDjkF_/s640/download-mahout.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri; mso-no-proof: yes;&quot;&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape
 id=&quot;Picture_x0020_1&quot; o:spid=&quot;_x0000_i1025&quot; type=&quot;#_x0000_t75&quot; style=&#39;width:481.5pt;
 height:168.75pt;visibility:visible;mso-wrap-style:square&#39;&gt;
 &lt;v:imagedata src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image005.png&quot;
  o:title=&quot;&quot;/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Download &#39;mahout-distribution-0.8.zip&#39;,
copy it to the clusters main node using RDP (Windows copy/paste over remote
desktop works), unzip it and place the files under &#39;C:\apps\dist\mahout-0.8&#39;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now that is in
place, we can start using Mahout for doing Machine Learning. The example I’m
going to run through here is that of a ‘classification’ model. This is a model
that takes incoming documents (think of the in general, a document could be an
email, a log file, a web-request, etc.) and tries to predict &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;something&lt;/i&gt; about this document. Now this
‘something’ is entirely up to us to decide upon. For emails the classic example
is to predict if an email is spam or not (we call that spam or ham). For
web-requests we could try to classify if the request is legitimate or a
denial-of-service (DoS) request sent from an attacker. Whatever it is we are
trying to predict, the general idea is that we must provide the algorithm with a
training data set in which we have told it for each document what the outcome
was (e.g. spam or ham), such that the algorithm can learn from this fact.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;But what do we get
out of that exactly? One document on its own is not going to be very helpful,
but the premise of machine learning is that you feed the model &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;tons&lt;/i&gt; of training data (this is where
machine learning ties into Big Data), and by churning through all this data,
the model will detect hidden patterns in the data that can be used to predict
the outcome of future documents (without knowing if they are actually spam or
not ahead of time).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So how does this
work? Let’s try to break it down. For reference I have used link [6] in the
bottom to get started on this, but that introduction is based on Mahout 0.5
which is outdated by now, so I would not suggest following it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We need to perform
the following steps for making a classification algorithm:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l1 level1 lfo1; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Upload the input
data that we want to categorize in HDFS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l1 level1 lfo1; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Prepare the data by converting it to input vectors
(more on that later)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l1 level1 lfo1; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;3.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Train the machine learning algorithm&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l1 level1 lfo1; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;4.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Test the machine
learning algorithm&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Creating the data
set&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We need a data set
to train on, you could try using your own, but I would suggest running through
this exercise with the sample provided by Spam Assassin as I’m doing it here.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;On your local
machine, create a new directory named ‘dataset’. Download the following files: &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://spamassassin.apache.org/publiccorpus/20021010_easy_ham.tar.bz2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;ham&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; and &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://spamassassin.apache.org/publiccorpus/20021010_spam.tar.bz2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;spam&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; and unzip them
under ‘dataset\ham’ and ‘dataset\spam’ respectively (These are ‘*.tar.bz2’
files so you need an unzip tool like Winzip or 7-Zip to extract them
unfortunately). Now zip up the entire ‘dataset’ folder and copy it onto the
main cluster node (use RDP again). Remote into the main node and create a
‘work’ folder under ‘c:\apps\dist\mahout-0.8\’ and extract your data files
there.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now we need to
upload the data set to HDFS. Start a ‘Hadoop Command Line’ prompt and enter:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cd
c:\apps\dist\mahout-0.8\work&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Hadoop fs –put
dataset dataset&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This can take a
while. After it completes, your data is now stored in HDFS in a folder named
‘dataset’.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Converting data
set to input vectors&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now we need to
take all of these input text files and convert them to something Mahout’s
training algorithms can use – they need to be ‘vectorized’. In the ‘Hadoop
Command Line’ prompt execute the following commands:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SET
MahoutDir=c:\apps\dist\mahout-0.8&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hadoop jar
%MahoutDir%\mahout-examples-0.8-job.jar org.apache.mahout.driver.MahoutDriver
seqdirectory -i /user/admin/dataset -o /user/admin/dataset-seq -ow&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; text-indent: 65.2pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;hadoop jar %MahoutDir%\mahout-examples-0.8-job.jar
org.apache.mahout.driver.MahoutDriver seq2sparse -i /user/admin/dataset-seq -o
/user/admin/dataset-vectors -lnorm -nv -wt tfidf&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This converts the
input text files to Hadoop vectors. So what happened here? We are telling
Hadoop to load the Mahout package called ‘mahout-examples-0.8-job.jar’ (this
holds the MapReduce jobs required for running the examples packaged with Mahout),
then we tell it to make use of the MahoutDriver Java class which sets up
everything to run Mahout commands (this is my interpretation because I really
don’t know what goes on behind the scenes…) then finally we call two Mahout commands,
seqdirectory and seq2sparse with some parameters pointing to our dataset.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now the next part
is splitting the resulting vectors into two sets, one we use for training the
algorithm, the other one is for testing. We hide the testing vectors from the
model and only after it has been fully trained, we let it try to classify the
testing vectors without telling it what is ham or spam (don’t worry Mahout will
take care of this for us later on).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Splitting is done
using:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hadoop jar
%MahoutDir%\mahout-examples-0.8-job.jar org.apache.mahout.driver.MahoutDriver
split -i /user/admin/dataset-vectors/tfidf-vectors --trainingOutput
/user/admin/train-vectors --testOutput /user/admin/test-vectors
--randomSelectionPct 40 --overwrite --sequenceFiles -xm sequential&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This splits 40%
into testing vectors and the remaining 60% into training vectors. This
concludes the preparation step.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Training the
Machine Learning model&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is probably
the easiest step, to train a machine learning model using the Naïve Bayes model
run the following command:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hadoop jar
%MahoutDir%\mahout-examples-0.8-job.jar org.apache.mahout.driver.MahoutDriver
trainnb -i /user/admin/train-vectors -el -o /user/admin/model -li
/user/admin/labelindex -ow&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Testing the
Machine Learning model&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Also an easy step,
run:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hadoop jar
%MahoutDir%\mahout-examples-0.8-job.jar org.apache.mahout.driver.MahoutDriver
testnb -i /user/admin/test-vectors -m /user/admin/model -l
/user/admin/labelindex -ow -o /user/admin/testing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;After the job
completes it will spit out the result of the test, indication how accurate the
model was in prediction spam, and details on classification errors.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Closing remarks&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;There are a couple
of gotchas when working with Hadoop/Mahout. Some that I have found are that you
need to provide absolute paths (like /user/admin/dataset) to the input and
output data, otherwise you will run into problems where Mahout stores
intermediate files under the wrong user directory because it is impersonating
another user (hdp).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I’ve also found
that if your input documents are very large in size (10+ MB), you can run into
’heap space’ exceptions. It should not be a problem with the sample I provided
here, but if you train on your own data, it could be an issue. I simply deleted
the input samples that were very large to avoid this problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Finally, the
algorithm I’ve been using is Naïve Bayes, and it is a very simple Machine
Learning algorithm, which usually does not give high accuracy on predictions
(say 95+%). The field of Machine Learning has develop better algorithms, but unfortunately
Mahout is missing support for some very powerful algorithms like Support Vector
Machines (SVM) which are very popular in Machine Learning.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This example
demonstrated how to apply Machine Learning to classify spam, but as I mentioned
previously you can apply it to any text documents just by replacing the data
set with your own as long as you can provide sufficient data samples and
accurately categorize the training data, you should be able to train a machine
learning model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;Links&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[1]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;a href=&quot;http://hadoop.apache.org/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Official Hadoop website&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[2]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;a href=&quot;http://mahout.apache.org/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Official Mahout website&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[3]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;a href=&quot;http://www.windowsazure.com/en-us/pricing/free-trial/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Windows Azure free-trial&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[4]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;a href=&quot;http://www.windowsazure.com/en-us/manage/services/hdinsight/get-started-hdinsight/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Getting Started with Windows
Azure HDInsight Service&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[5]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;a href=&quot;http://www.windowsazure.com/en-us/manage/services/hdinsight/recommendation-engine-using-mahout/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Simple recommendation engine
using Apache Mahout&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri; text-decoration: none; text-underline: none;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;u&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[6]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;a href=&quot;http://searchhub.org/2011/05/04/an-introductory-how-to-build-a-spam-filter-server-with-mahout/&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Introduction to building a
spam filter with Mahout (outdated)&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;MsoHyperlink&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri; text-decoration: none; text-underline: none;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[7]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;a href=&quot;http://chimpler.wordpress.com/2013/03/13/using-the-mahout-naive-bayes-classifier-to-automatically-classify-twitter-messages/&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Using
Mahout to classify tweets&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-add-space: auto; mso-list: l0 level1 lfo3; text-indent: -18pt;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[8]&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;a href=&quot;http://hadoop.apache.org/docs/r0.18.3/hdfs_shell.html&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Hadoop Shell Commands&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;color: black; mso-ansi-language: EN-US; mso-ascii-font-family: Calibri; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: DA; mso-hansi-font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot; style=&quot;mso-ansi-language: EN-US;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/5075020638720444343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2013/09/large-scale-machine-learning-powered-by.html#comment-form' title='43 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5075020638720444343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5075020638720444343'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2013/09/large-scale-machine-learning-powered-by.html' title='Large Scale Machine Learning powered by Windows Azure HDInsight'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAmjC_lJAwvZOXPNtYNglBVkzr7Rb6WnSHuXr2CBz-_fd5RZxThsWgSU5YBySPAEOMWMVJFzKFtjRv2-eTJittJVwZU7fCmAOu61jD_NcnEcxsgWt0QB2GsthUu0h8T8BHN9EnsNwCgVWd/s72-c/azure-hdinsight.png" height="72" width="72"/><thr:total>43</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-4058278852475791383</id><published>2012-12-12T04:45:00.000-08:00</published><updated>2012-12-12T04:45:11.752-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="explore"/><category scheme="http://www.blogger.com/atom/ns#" term="merge"/><category scheme="http://www.blogger.com/atom/ns#" term="merging"/><category scheme="http://www.blogger.com/atom/ns#" term="model"/><category scheme="http://www.blogger.com/atom/ns#" term="patent"/><category scheme="http://www.blogger.com/atom/ns#" term="spec explorer"/><category scheme="http://www.blogger.com/atom/ns#" term="state-query"/><title type='text'>State-Query Models</title><content type='html'>

&lt;span style=&quot;font-family: Calibri;&quot;&gt;It’s been a while since I have had time to write on my blog.
In the meantime I have been busy being on paternity leave (we get 10 weeks in
Denmark!), changed roles, and went through re-organization in NAV. All bad
excuses for not taking the time to write blog posts – apologies for that!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;I’m going to shift gears a bit from now on. We recently
filed a patent application&lt;sup&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/sup&gt; on a new approach to Model-Based
Testing. The patent revolves around how to apply Model-Based Testing to systems
under test where state is contained in a data source, for instance a database.
With this new approach models emerge from the responses of the system under
test instead of through careful crafting of state-machines. This sounds very
fancy, but in reality we probe the system through exercising automated action,
and record how it responds by tracing the impact on the data source. With this
approach a state model emerges, which has some surprisingly nice benefits.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h1 style=&quot;margin: 12pt 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2e74b5;&quot;&gt;&lt;span style=&quot;font-family: Calibri Light;&quot;&gt;State-queries vs. state-machines&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;At the hearth of the invention lies the replacement of
finite-state-machines with state-queries.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Allow me to illustrate by example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt 36pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Consider a sales order in an ERP
system. This is a document that has a header with some general information and
some lines detailing what items/resources/etc. is being sold. A very simple
model could consist of rules for creating an empty sales order, adding a sales
line to the document and posting it. A typical Model-generated test case could
be to create an empty sales document add a sales line and post it. However, the
model could also just create a blank sales order and try to post it, which
should result in an error.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;To model this with Spec Explorer we would need to create a
state-machine which counts the number of sales orders, and how many lines each
sales order has. We would then need to build logic to increase counters
whenever we create new sales orders or add new lines, and to check that we are
able to post a sales order with lines.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;In Spec Explorer such a model could look like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQzzFVtsStLIqS4xOfcf50mwI6_UJt6GtiTNfm0PIgqz0cJpx442uC8H5Z0r3-gkymNFUC1-tFm9ZJFVY24LeihjrQj90CN80F0Lap5xG2vz4aal0JtpXy9b3yecnY_iYaEiVBXByOH409/s1600/SalesOrderModel.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQzzFVtsStLIqS4xOfcf50mwI6_UJt6GtiTNfm0PIgqz0cJpx442uC8H5Z0r3-gkymNFUC1-tFm9ZJFVY24LeihjrQj90CN80F0Lap5xG2vz4aal0JtpXy9b3yecnY_iYaEiVBXByOH409/s640/SalesOrderModel.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;&lt;v:stroke joinstyle=&quot;miter&quot;&gt;&lt;v:formulas&gt;&lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;&lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;&lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;&lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;&lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;&lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;&lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;&lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;&lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;&lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;&lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;&lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;&lt;v:shape id=&quot;Picture_x0020_3&quot; o:spid=&quot;_x0000_i1029&quot; style=&quot;height: 208.2pt; mso-wrap-style: square; visibility: visible; width: 416.4pt;&quot; type=&quot;#_x0000_t75&quot;&gt;&lt;v:imagedata o:title=&quot;&quot; src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png&quot;&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/v:path&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Where the state (x:y) represents &lt;em&gt;x&lt;/em&gt; sales orders and &lt;em&gt;y&lt;/em&gt; sales lines. However, the information regarding number of sales orders
and the number of lines on each is typically already stored in some backend
database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;In our new approach the strategy is to create SQL queries
that selects the relevant information from the database, instead of
constructing a fictive state-machine. These so-called state-queries are then
evaluated after every single rule is exercised to determine in what state the
model is. In our example the following SQL query would select all relevant
state-variables directly from the system:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[Document Type],&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[No],&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: magenta;&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;(*) &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;&quot;No of lines&quot;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[Sales Header]&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;h&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;color: grey; font-family: Consolas; font-size: 9.5pt;&quot;&gt;LEFT&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;JOIN&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[Sales Line]&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;l&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;color: teal; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: FR;&quot;&gt;h&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: FR;&quot;&gt;.&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;color: teal; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: FR;&quot;&gt;[Document Type]&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: FR;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[Document Type]&lt;/span&gt; &lt;span style=&quot;color: grey;&quot;&gt;AND&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span lang=&quot;FR&quot; style=&quot;font-family: Consolas; font-size: 9.5pt; mso-ansi-language: FR;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: 9.5pt;&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Consolas; font-size: 9.5pt;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: teal; font-family: Consolas; font-size: 9.5pt;&quot;&gt;[No]&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: teal;&quot;&gt;l&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[Document No]&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;GROUP&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;BY&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[Document Type]&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: teal;&quot;&gt;[No]&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;An example execution of this query could yield the following
dataset:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidmq3BEPVrIflzFFvGLcbHIjALKrmIsVwjywQ6f_hB1w7quemGqPI0e5w8HX6Mt4GZygeK5lndxAMga25gNlTCZQGB8RbSUMokv4y6xAtcy4xzTnFjsN7-6TJ7wDH4CBqMXEdMRufKi1ds/s1600/sampledataset.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidmq3BEPVrIflzFFvGLcbHIjALKrmIsVwjywQ6f_hB1w7quemGqPI0e5w8HX6Mt4GZygeK5lndxAMga25gNlTCZQGB8RbSUMokv4y6xAtcy4xzTnFjsN7-6TJ7wDH4CBqMXEdMRufKi1ds/s1600/sampledataset.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;&quot;&gt;&lt;v:shape id=&quot;Picture_x0020_2&quot; o:spid=&quot;_x0000_i1028&quot; style=&quot;height: 1in; mso-wrap-style: square; visibility: visible; width: 185.4pt;&quot; type=&quot;#_x0000_t75&quot;&gt;
 &lt;v:imagedata o:title=&quot;&quot; src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image002.png&quot;&gt;
&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The resulting dataset contains all the information the model
needs to determine if it can add lines or post sales orders, and it was
generated at runtime by directly querying the database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h1 style=&quot;margin: 12pt 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2e74b5;&quot;&gt;&lt;span style=&quot;font-family: Calibri Light;&quot;&gt;Exploring state-query models&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Exploration of state-query models is ‘on-the-fly’ testing.
This means that the model is being explored by performing actions on the live
system under test. Between each executed action the state-queries are evaluated
on the database to determine the current state of the system under test. If the
combined result of the state-queries is unique, then the newly discovered state
is stored.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The following UML diagram shows how to conceptually explore
a state-query model in a depth-first fashion:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJVUSlvAPBBmVejafu1N-f3gFjjI-dZw52KMCFtY9I-Dai5stQZE0BGAYov4LnqqNSUi3CyUPE7c5yQm4VjAJCKVy97wewcUNVtkY92rmcYwkmuOIVOPdGTl1tiO2hXtQLvgwyfN9kSaV2/s1600/depth_explore_uml.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJVUSlvAPBBmVejafu1N-f3gFjjI-dZw52KMCFtY9I-Dai5stQZE0BGAYov4LnqqNSUi3CyUPE7c5yQm4VjAJCKVy97wewcUNVtkY92rmcYwkmuOIVOPdGTl1tiO2hXtQLvgwyfN9kSaV2/s640/depth_explore_uml.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;v:shape id=&quot;_x0000_i1025&quot; o:ole=&quot;&quot; style=&quot;height: 190.2pt; width: 469.2pt;&quot; type=&quot;#_x0000_t75&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;
 &lt;v:imagedata o:title=&quot;&quot; src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image003.emz&quot;&gt;
&lt;/v:imagedata&gt;&lt;/span&gt;&lt;/v:shape&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice that for the state-query model to be feasible we must
provide a mechanism for restoring a previous state (the ‘Restore database’
action). If the system under test stores its full state in the database (which
is common for many service architectures), then this is obtained through a database
restore. State restore is typically the most costly operation in the
exploration algorithm. However, there are many ways to optimize this step, for
example in NAV we track all changes to tables and then we can easily roll them
back efficiently.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h1 style=&quot;margin: 12pt 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2e74b5;&quot;&gt;&lt;span style=&quot;font-family: Calibri Light;&quot;&gt;Seamlessly merging of models&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt; line-height: 107%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The greatest benefit of this approach is that the emergent
state model is coupled to the system implementation (and not some artificial
state-machine), this implies that any integration scenarios (from the outside
of the model) that stimulates a response in the system also stimulates the same
response in the model. This means that we can create small models of
sub-systems of the full system that still responds to integration scenarios.
These small models are easily verifiable and once we have confidence that the
small models works as we expect, they can seamlessly be merge into larger more
complicated models that we would still expect to work. Again, very fancy, but
let me continue the example and the benefits should be very clear:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt 36pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Keeping in mind our original sales
order model, we would now also like to model a sales quote document. This model
would look almost identical to our first model, but everything would revolve
around quotes. The one thing that is different is that a quote cannot be
posted, it needs to be converted to an order first.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Where we again to use Spec Explorer we could use a new set
of variables to track sales quote documents and the number of lines on each in
a new model. But what happens now when we convert the sales quote to an order?
How do we make that work with the sales order model? The conversion would never
register in the sales order model, because the models know nothing of each
other. We would have to bring in the functionality from the sales order model into
the sales quote model (or make a third model), and explicitly enforce the
creation of a sales order when a quote is converted. But there is no good way
to do that – we are forced to either duplicate the sales order model or couple
the two models together. If we duplicate we have redundant code, if we couple
then the models become dependent on each other, and we can no longer change one
without risk of breaking the other.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;However, with our new approach, we can simply ignore this
problem! We can just model the sales quote as if it was independent of the
sales order. Resulting in another state variable query that would count sales
quotes and the number of lines on them. In a stand-alone sales quote model what
would happen when the model tries to convert a quote to an order? Even though
the system under test will convert the quote to an order, &lt;i&gt;the quote would
simply appear to have disappeared&lt;/i&gt; – the model is not tracking sales orders,
so it will not notice the appearance of a new sales order in the system. Conceptually
the models would be disjoined:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsXRsuD-oPjXtE5DHqO5zWb1DHv7e9YSqzJnQ_XcTZCOZ3Zvjrd-PWBdf6MIuFA-OXNmnbV-B39SYcGQJfGLXJDzP8plUKNQgwtuY_TczR3zuKohBwjTcgRoU4z8r1TNGbaZsmqxUP7IeC/s1600/disjoint_models.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsXRsuD-oPjXtE5DHqO5zWb1DHv7e9YSqzJnQ_XcTZCOZ3Zvjrd-PWBdf6MIuFA-OXNmnbV-B39SYcGQJfGLXJDzP8plUKNQgwtuY_TczR3zuKohBwjTcgRoU4z8r1TNGbaZsmqxUP7IeC/s400/disjoint_models.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;However, were we to merge the state queries of both models
into a new model, this new model &lt;i&gt;would&lt;/i&gt; notice the appearance of a new
sales order:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVAVqQKpLfZcQuRgB6tnvuP-7cJUrXh1Fi0t7ExmYRRuBegnlUs00pIn5PWhwihNJdiWlGiUU88SUkbNfRDhX8cWm-SIioD8U85VTmt0Al41O10XV1zBrCTG6Cn6hrnkxfBtd_XkC7gkrO/s1600/merged_modls.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;287&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVAVqQKpLfZcQuRgB6tnvuP-7cJUrXh1Fi0t7ExmYRRuBegnlUs00pIn5PWhwihNJdiWlGiUU88SUkbNfRDhX8cWm-SIioD8U85VTmt0Al41O10XV1zBrCTG6Cn6hrnkxfBtd_XkC7gkrO/s400/merged_modls.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;v:shape id=&quot;_x0000_i1027&quot; o:ole=&quot;&quot; style=&quot;height: 211.2pt; width: 297.6pt;&quot; type=&quot;#_x0000_t75&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;
 &lt;v:imagedata o:title=&quot;&quot; src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image005.emz&quot;&gt;
&lt;/v:imagedata&gt;&lt;/span&gt;&lt;/v:shape&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;It gets even better, not only will we detect the appearance
of a sales order, the sales order sub-model &lt;i&gt;would not know the difference&lt;/i&gt;
between a sales order generated by itself (the sales order model) and one
converted from a quote. This leads to the automatic generation of &lt;i&gt;integration
scenarios&lt;/i&gt; (green path in the picture) between models.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The merged model would automatically detect and generate
test cases for this integration scenario: creating a sales quote, adding lines
to the quote, converting the quote to an order and posting this newly generated
order – without us ever telling it anything about integration scenarios between
sales quotes and orders. It simply falls out of the new approach for free.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h1 style=&quot;margin: 12pt 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2e74b5;&quot;&gt;&lt;span style=&quot;font-family: Calibri Light;&quot;&gt;Caveat&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is all nice and dandy, but one thing to be wary about
is the fact that the model is coupled to the system under test. In traditional
Model-Based Testing this is not the case. When we couple the model and the
system, then we cannot distinguish between bugs in the model vs. bugs in the
system under test. Furthermore, if we change behavior of the system, the model
will follow suit. In short:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 10pt 43.2pt 8pt;&quot;&gt;
&lt;em&gt;&lt;span style=&quot;color: #404040;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The model reveals &lt;u&gt;how&lt;/u&gt; the system behaves, not whether
that behavior is correct or not.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;However, it is relatively easy to visually inspect a small
model and determine if the behavior is correct or not. The strength of
state-query models is that we inspect each of the individual models in
isolation and validate conformance, then we bring the small models together
into one (much) larger merged model, which is validated against all the validation
rules of the individual models.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;In the coming articles we will drill-down further into this caveat,
and provide some mechanisms for decoupling your Model-Based Tests from the
system under test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h1 style=&quot;margin: 12pt 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2e74b5;&quot;&gt;&lt;span style=&quot;font-family: Calibri Light;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;In this article, we presented a novel innovation in the
field of Model-Based Testing in which we represent the state of the system
under test through the result of a set of state-queries executed against the
data source backing the system. Using this approach we can construct many small
models that validates conformance of system components and then seamlessly
merge these into a larger model which models bigger parts of the system (or
even the entire system).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;


&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 8pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;sup&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/sup&gt;U.S Patent Application No. 13/571717 (AUTOMATIC
VERIFICATION OF DATA SOURCES)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/4058278852475791383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/12/state-query-models.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/4058278852475791383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/4058278852475791383'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/12/state-query-models.html' title='State-Query Models'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQzzFVtsStLIqS4xOfcf50mwI6_UJt6GtiTNfm0PIgqz0cJpx442uC8H5Z0r3-gkymNFUC1-tFm9ZJFVY24LeihjrQj90CN80F0Lap5xG2vz4aal0JtpXy9b3yecnY_iYaEiVBXByOH409/s72-c/SalesOrderModel.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-1156989532362816774</id><published>2012-11-21T05:07:00.000-08:00</published><updated>2012-11-21T05:08:11.781-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="critical path"/><category scheme="http://www.blogger.com/atom/ns#" term="dependencies"/><category scheme="http://www.blogger.com/atom/ns#" term="heat-map"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="random"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="stochastic"/><category scheme="http://www.blogger.com/atom/ns#" term="system"/><title type='text'>Simulating Stochastic Models</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;Recently I’ve been tasked with working on an infrastructure
system which comprises several computationally intensive tasks that can be
scheduled on a series of host machines. Some tasks have dependencies on other tasks,
and cannot be scheduled before its dependencies have finished. In a simplified
setup we assume that any task can run on any machine, provided that machine is
not busy with running another task.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The following picture illustrates the system&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFRoivksnwJleNQVgNJC2LCTAU71H1qDhDjGw3u44-Er0e68QnbhitUW9Oay3e1nMJR6ZZDZne-MSqQLPz45Kz-Ex-QPoZB_J_bNse1BYD7x1DTRWX3XFG0NCjqy5B8VXBImL42hfyO89P/s1600/concept.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFRoivksnwJleNQVgNJC2LCTAU71H1qDhDjGw3u44-Er0e68QnbhitUW9Oay3e1nMJR6ZZDZne-MSqQLPz45Kz-Ex-QPoZB_J_bNse1BYD7x1DTRWX3XFG0NCjqy5B8VXBImL42hfyO89P/s400/concept.PNG&quot; width=&quot;286&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Host A runs task 1 and 3, while host B runs task 2 and 4.
Task 4 has a dependency on task 1 and task 3 has one on task 2. When all tasks
are completed the job is considered completed. It is evident from the picture
that a task (task 3) may be delayed in its scheduling even though its
dependencies are satisfied due to resource constraints.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Runtime and randomness&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Each task takes a finite amount of time to complete,
illustrated by the size of the task in the picture. Furthermore, the runtime of
the tasks are highly stochastic as they are influenced by CPU load, network
latency, IO latency, even build-in randomness in the tasks, etc. This causes
the overall system to behave stochastically. At first hand one would think that
we could just look at average runtimes of individual tasks to get an average
job runtime, however this is not going to give an accurate response of the
system.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now, traditionally I would model this problem in Spec
Explorer, but in this case the system is already represented by a model, namely
the dependency tree of the job&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7YAJvoH1rLvgjBkqLbyEiuB81LpjWJpzRsCg60OBPHoqIneoTXpx4C4TuxAv0PQJAIv_cctg79eGpWi6p49Qeqfw_VuBKW7l_CpbaZthZBQmKARXlEDx8afT2uTl5L9YstZwpE_skZvVB/s1600/dependencytree.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;192&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7YAJvoH1rLvgjBkqLbyEiuB81LpjWJpzRsCg60OBPHoqIneoTXpx4C4TuxAv0PQJAIv_cctg79eGpWi6p49Qeqfw_VuBKW7l_CpbaZthZBQmKARXlEDx8afT2uTl5L9YstZwpE_skZvVB/s400/dependencytree.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;!--[if gte vml 1]&gt;&lt;v:shape id=&quot;_x0000_i1026&quot; type=&quot;#_x0000_t75&quot;
 style=&#39;width:382.8pt;height:184.2pt&#39; o:ole=&quot;&quot;&gt;
 &lt;v:imagedata src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image003.emz&quot;
  o:title=&quot;&quot;/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:OLEObject Type=&quot;Embed&quot; ProgID=&quot;Visio.Drawing.11&quot; ShapeID=&quot;_x0000_i1026&quot;
  DrawAspect=&quot;Content&quot; ObjectID=&quot;_1415011558&quot;&gt;
 &lt;/o:OLEObject&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;This allows me to write a simulation tool instead.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Simulation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The idea about the tool is to simulation how the system
would stochastically schedule tasks in a single job. This is called a sample.
Once this is working, we can set the tool to repeatedly simulate the same
system, producing thousands of samples. We can then measure the average job
runtime of all the produced samples. This is called Monte Carlo Simulation and
is an exceptionally powerful technique. It turns out that the measurement error
on the sample mean, is reduced by the inverse square root of the number of
samples – regardless of what metric is measured, and regardless of what system
is measured! Let’s take a step back and think about the ramifications of that.
That means, no matter how complicated we make the stochastic system, the
measurements are going to become more and more accurate, the more samples we
take from the system. So, say we want to model re-running failing tasks for
instance. No problems, if a task fails (this is also stochastically determined)
we let the system reschedule it. We sample the system a couple of thousand
times and our metrics are updated with the new mean job execution time!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Furthermore, the model was able to predict and generate a
heat-map of the bottlenecks of the system, which I’d like to share with you for
inspiration:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxaMsJd5th6ulj3eA-fDs72IXRLhyphenhyphendxTKvB3-Dr_oWLPeCgVwjppxB-DrizqfrnlURQczIphuoJ930zPolTK8keKQ2KYU0DtG2TJQRhGSOtavPYIuznvEF_cKDSiPYljhjOVM5cyWGRlH7/s1600/heatmap.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;464&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxaMsJd5th6ulj3eA-fDs72IXRLhyphenhyphendxTKvB3-Dr_oWLPeCgVwjppxB-DrizqfrnlURQczIphuoJ930zPolTK8keKQ2KYU0DtG2TJQRhGSOtavPYIuznvEF_cKDSiPYljhjOVM5cyWGRlH7/s640/heatmap.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape
 id=&quot;Picture_x0020_2&quot; o:spid=&quot;_x0000_i1027&quot; type=&quot;#_x0000_t75&quot; style=&#39;width:499.2pt;
 height:363pt;visibility:visible;mso-wrap-style:square&#39;&gt;
 &lt;v:imagedata src=&quot;file:///C:\Users\simej\AppData\Local\Temp\msohtmlclip1\01\clip_image005.png&quot;
  o:title=&quot;&quot;/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The redder the task the more often it appeared on the
critical-path of the system (the path determines the overall execution time). By
reducing the time of the critical path, you reduce the overall execution time.
The problem is that in a stochastic system the critical path changes between
executions. Therefore, this heat-map is extremely valuable information because
it allows us to direct our effort to the tasks that most often appear on the
critical path.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;What does this have to do with model
based testing?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Well, think about it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;i&gt;Is there an underlying model?&lt;/i&gt; – Yes! However, it’s
not a finite state model supposed to simulate the system under test, but a
stochastic model that is the system under test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;i&gt;But will it find any bugs?&lt;/i&gt; – Arguably the model is
not designed to find bugs in the system (because the model and system is the
same, which makes it impossible to do so…). Yet, the simulations will help
detect bottlenecks, resource starvation, mean critical path, optimum number of
resources, optimum re-run strategy, etc. These are not bugs as we see them
traditionally. However, they are all system characteristics which we are trying
to improve. So they could just as well be interpreted as bugs!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;In some extreme cases you could also prevent bugs by
specifying acceptable intervals for your measurements – for example, we could
state that no job may take more than four hours to complete, then if a
simulated sample happens to exceed this limit, we may conclude that the system
is defective.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;
&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;What I wanted to demonstrate with this post is that Model-Based
Testing is not just about Finite-State models and Spec Explorer. The
fundamentals of modeling applies to many problems. In my example I was lucky
enough to be working with a system that could be described through a model. When
you are faced with a new problem, try thinking out-side of the box, in many
cases modeling turns out to be a valuable tool in your toolbox.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/1156989532362816774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/11/modeling-stochastic-system.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/1156989532362816774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/1156989532362816774'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/11/modeling-stochastic-system.html' title='Simulating Stochastic Models'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFRoivksnwJleNQVgNJC2LCTAU71H1qDhDjGw3u44-Er0e68QnbhitUW9Oay3e1nMJR6ZZDZne-MSqQLPz45Kz-Ex-QPoZB_J_bNse1BYD7x1DTRWX3XFG0NCjqy5B8VXBImL42hfyO89P/s72-c/concept.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-7829254299433016724</id><published>2012-06-24T21:51:00.001-07:00</published><updated>2012-06-25T04:39:11.278-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cars"/><category scheme="http://www.blogger.com/atom/ns#" term="Ferrari"/><category scheme="http://www.blogger.com/atom/ns#" term="goat"/><category scheme="http://www.blogger.com/atom/ns#" term="lets make a deal"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="monty hall"/><category scheme="http://www.blogger.com/atom/ns#" term="probability"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="slicing"/><category scheme="http://www.blogger.com/atom/ns#" term="stochastic"/><title type='text'>Solving ‘The Monty Hall Problem’ using Models</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Today is about my favorite probability puzzle – The Monty Hall problem. If you haven’t heard of it before you are in for a treat. The problem stated goes as follows (from &lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Monty_Hall_problem&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Wikipedia&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 36pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Suppose you&#39;re on a game show, and you&#39;re given the choice of three doors: Behind one door is a car; behind the others, goats*. You pick a door, say No. 1 [but the door is not opened], and the host, who knows what&#39;s behind the doors, opens another door, say No. 3, which has a goat**. He then says to you, &quot;Do you want to pick door No. 2?&quot; Is it to your advantage to switch your choice? &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 36pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;Vos Savant&#39;s response was that the contestant should always switch to the other door.&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt; […]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 36pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Many readers refused to believe that switching is beneficial. After the Monty Hall problem appeared in Parade, approximately 10,000 readers, including nearly 1,000 with PhDs, wrote to the magazine claiming that vos Savant was wrong. (&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Monty_Hall_problem#CITEREFTierney1991&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;&lt;em&gt;Tierney 1991&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;) Even when given explanations, simulations, and formal mathematical proofs, many people still do not accept that switching is the best strategy.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin: 0cm 0cm 0pt 36pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;*The probability of the car being behind any door is uniformly 1/3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt 36pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;**The door that is opened has to have a goat behind it, and it cannot be the one you picked initially, in case the host has multiple choices it is assumed that s/he chooses uniformly at random&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The problem is brilliant in its simplicity and the correct answer feels extremely counter-intuitive at first. The natural tendency is to think that it makes no difference whether you switch or not – but the truth is that you &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;should&lt;/i&gt; switch! And hopefully once you are done reading this article you will be convinced why.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;For an in-depth explanation (although a little too narrative in my opinion) watch &lt;/span&gt;&lt;a href=&quot;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;frm=1&amp;amp;source=web&amp;amp;cd=11&amp;amp;ved=0CI4BELcCMAo&amp;amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dmhlc7peGlGg&amp;amp;ei=-H3gT4lWxIqyBuT24NAI&amp;amp;usg=AFQjCNHjsyqqIFKb_Wx8F28bYqBOvAPDaQ&amp;amp;sig2=MON5jVT6PzvPKFzPl6-U5Q&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;this&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; YouTube video – and if you think the answer is obvious, just scan the comments on the video to convince yourself that people have a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;hard&lt;/i&gt; time understanding this answer!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Solving the problem through modeling&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Let’s take a look at how we can tackle this problem in the world of Model-Based Testing [1]. This article is special in that &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;I’m not going to have a system under test&lt;/b&gt; – there is nothing to test here! Instead, what I’ll be doing is constructing a model that will be useful for simulating the flow of the Monty Hall problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The model state machine consists of the following variables:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; NumberOfDoors = 3;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; DoorWithPrize = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; first_choice = -1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; revealed_door = -1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; final_choice = -1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;First, one thing I’d like to make clear is that I’m simplifying the problem by &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;fixing&lt;/i&gt; the door that contains the prize to be the first door – this does not make any difference, because the problem statement is equivalent no matter which door the prize is behind (likewise you could fix the initial choice and have the location of the prize be random). If you don’t believe this, then feel free to enumerate both policies for all three prize locations.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To break the model down, the game show contains three stages, they are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Pick your initial choice of door&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Game host reveals a goat behind another door&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 10pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;3)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;You either switch or stick with your door&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We will be modeling these stages as rules, and then define a slicing scenario that dictates the two choices of policies we have (switch/stick with choice).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The rules of the model become:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Chooses a first choice door between 0 and 2&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;PickDoor()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; PickDoorRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;first_choice = &lt;span style=&quot;color: #2b91af;&quot;&gt;Choice&lt;/span&gt;.Some&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;(i =&amp;gt; i &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; NumberOfDoors);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; first_choice;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Chooses a door to reveal between 0 and 2 that:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// * Is not our first choice&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// * Is not the door with the prize (door: 0)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;RevealDoor()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; RevealDoorRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;revealed_door = &lt;span style=&quot;color: #2b91af;&quot;&gt;Choice&lt;/span&gt;.Some&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;(i =&amp;gt; i &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; NumberOfDoors &amp;amp;&amp;amp; i != first_choice &amp;amp;&amp;amp; i != DoorWithPrize);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; revealed_door;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Switches our choice of door and saves the value in final_choice, by picking a door between 0 and 2 that:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// * Is not our first choice&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// * Is not the revealed door&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;SwitchDoor()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; SwitchDoorRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;final_choice = &lt;span style=&quot;color: #2b91af;&quot;&gt;Choice&lt;/span&gt;.Some&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;(i =&amp;gt; i &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; NumberOfDoors &amp;amp;&amp;amp; i != first_choice &amp;amp;&amp;amp; i != revealed_door);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; final_choice;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Simply sticks with our first choice by setting final choice = first choice&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;StickWithDoor()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; StickWithDoorRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;final_choice = first_choice;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; final_choice;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice that we leverage Spec Explorers ability to handle stochastic choices! The model does not know up-front which door the contestant will start out picking, and neither does it know which door the game host will reveal.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So, we could simply explore the model composing these rules, but that model would be nonsensical because it violates the rule of the game show – e.g. it would allow the game host to reveal two doors, etc. Therefore, we need to constrain the model into a meaningful slice. We have two policies so we need two slices; the first slice is for ‘sticking with your initial choice’:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: 9.5pt;&quot;&gt;/// The scenario is equivalent to sticking with your choice in the &#39;Let&#39;s make a deal&#39; game show&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; DontSwitchScenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(PickDoor; RevealDoor; StickWithDoor)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; MontyHallDontSwitchModel() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DontSwitchScenario || MontyHallRules&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Let’s explore this model and have a look at the results:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaJ0NDQn1p7Bueb8u5OgCdUyqiFRn98MYNDfNU2Es3JAkE0F6WcxlI-W-MyE-ApS2JqtkN2KaXvf2euGoPCb0mpYghhCZTEPwvnwcAxSoKZaqOv2adndo6-5vOy3PyRGFbwNbM427VNDW-/s1600/stick_with_choice.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;315&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaJ0NDQn1p7Bueb8u5OgCdUyqiFRn98MYNDfNU2Es3JAkE0F6WcxlI-W-MyE-ApS2JqtkN2KaXvf2euGoPCb0mpYghhCZTEPwvnwcAxSoKZaqOv2adndo6-5vOy3PyRGFbwNbM427VNDW-/s400/stick_with_choice.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;  &lt;v:stroke joinstyle=&quot;miter&quot;&gt;  &lt;v:formulas&gt;   &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;   &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;   &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;   &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;   &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;  &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;  &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;  &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/span&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The state bubbles show the currently selected door, and at the end it includes the outcome – whether we found a Ferrari or a goat behind our final choice door.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;From a quick glance of this model it looks like we are in pretty good shape – we see two goats versus two Ferraris. But we need to read the picture correctly, actually we don’t decide which door is revealed, it is stochastically decided, meaning there is a 50/50 chance that either door 1 or door 2 is revealed – however, the final outcome is the same – we win no matter which door the host reveals under this policy (which is expected because our choice is unaffected by the host’s choice when we stick with the initial choice).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To compute the expected outcome for this model observe that we pick the initial door randomly with 1/3 probability, then in two out of three options the game host can only reveal one door (with probability 1), and in the final option the game host picks one of the remaining doors with probability 0.5. Getting the Ferrari has utility 1 and the goat has 0. The expected outcome is then:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;E[MontyHall|Stick with choice] = 1/3 * 0 + 1/3 * 0 + 1/3 * (1/2 * 1 + 1/2 * 1) = 1/3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The fact that there are two ways of winning when we have picked door zero initially should not count double. What matters is that given our &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;initial&lt;/i&gt; three options, which &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;paths&lt;/i&gt; will give what outcome? In our case the two left-most paths will result in ‘winning’ a goat, where the right-most choice (under our policy) will win us a Ferrari! Our chance of winning the Ferrari is thus 1/3.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Next, let’s look at the switching policy:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: green; font-family: Consolas; font-size: 9.5pt;&quot;&gt;/// The scenario is equivalent to switching your choice in the &#39;Let&#39;s make a deal&#39; game show&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; SwitchScenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(PickDoor; RevealDoor; SwitchDoor)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; MontyHallSwitchModel() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SwitchScenario || MontyHallRules&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;It is clear that the only difference is in the third stage of the model, where we now switch our choice instead of sticking with it. The model looks slightly different:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTNxuaCsJgGZu4ZiJV9HdXKbMKHWEUSlj2GIusw9ziCp9bnQRcsgaVO7nhyTBpHySNxcaDTmEMphY_A5QB2lH2LTI1aGJYnWwsn95GF6OnE2TCzuHtv8xUK4-uATftJizL7CHwTfM90isW/s1600/switch_door.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTNxuaCsJgGZu4ZiJV9HdXKbMKHWEUSlj2GIusw9ziCp9bnQRcsgaVO7nhyTBpHySNxcaDTmEMphY_A5QB2lH2LTI1aGJYnWwsn95GF6OnE2TCzuHtv8xUK4-uATftJizL7CHwTfM90isW/s400/switch_door.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice now that the mechanics of the game have switched! Under the policy where we switch, two of our initial branches will lead to winning the Ferrari! Only one branch will lead us down the path where we ‘win’ a goat – again it does not matter whether the game host reveals door one or two, once we are down the path of picking door zero initially we are guaranteed to lose the game. The expected outcome is:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;E[MontyHall|Switch] = 1/3 * 1 + 1/3 * 1 + 1/3 * (1/2 * 0 + 1/2 * 0) = 2/3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The key to understanding this problem (in my opinion) lies with understanding what happens when the host reveals a door under the switching policy. Notice that under this policy the game host only has one option in two out of three cases – incidentally, in these two cases, when he reveals the door with the goat behind it he is consequently also revealing which door the Ferrari is behind!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We saw in this article how models can be useful for simulating problems without actually acting against a system under test. Modeling is a great technique for visualizing simulation results and through Spec Explorers powerful stochastic modeling feature you can simulate decision-trees for random processes, like the Monty Hall problem.&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;References&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;[1] &lt;a href=&quot;http://www.ge.tt/6RFluaJ/v/0?c&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Monty Hall Model&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/7829254299433016724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/06/solving-monty-hall-problem-using-models.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/7829254299433016724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/7829254299433016724'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/06/solving-monty-hall-problem-using-models.html' title='Solving ‘The Monty Hall Problem’ using Models'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaJ0NDQn1p7Bueb8u5OgCdUyqiFRn98MYNDfNU2Es3JAkE0F6WcxlI-W-MyE-ApS2JqtkN2KaXvf2euGoPCb0mpYghhCZTEPwvnwcAxSoKZaqOv2adndo6-5vOy3PyRGFbwNbM427VNDW-/s72-c/stick_with_choice.JPG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-3096535403598432435</id><published>2012-06-18T01:05:00.000-07:00</published><updated>2012-06-18T01:05:16.746-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fragile"/><category scheme="http://www.blogger.com/atom/ns#" term="mock"/><category scheme="http://www.blogger.com/atom/ns#" term="perception of time"/><category scheme="http://www.blogger.com/atom/ns#" term="performance test"/><category scheme="http://www.blogger.com/atom/ns#" term="regression test"/><category scheme="http://www.blogger.com/atom/ns#" term="test of time"/><category scheme="http://www.blogger.com/atom/ns#" term="time"/><category scheme="http://www.blogger.com/atom/ns#" term="unstable"/><title type='text'>Can your tests stand the ‘test of time’?</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Today I want to digress a bit from Model-Based Testing and talk about a general issue in software testing, applicable to all types of testing. My focus will be on the use of time-dependent methods in test code. These include library functions like ‘DateTime.Now’, reading the BIOS clock, retrieving the current time from a time server, etc. The use of time dependent methods can lead to unpredictable behavior and is a common source for fragility in tests.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;But first, let’s look at a definition of time. From &lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Time&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Wikipedia&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 36pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN; mso-bidi-font-weight: bold;&quot;&gt;Time&lt;/span&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt; is the indefinite continued progress of existence and events that occur in apparently irreversible succession from the past through the present to the future.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;There are two vital pieces of information in this definition. They are &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;continued progress&lt;/i&gt; and &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;irreversible&lt;/i&gt;. There is nothing about size and quantity of time in the definition. In fact our daily representation of time in hours, minutes, seconds, milliseconds, etc. is completely arbitrary. Instead I like to think of time in a mathematical sense, as a strictly increasing series t : t&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i&lt;/span&gt;&lt;/sub&gt; &amp;lt; t&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i+1&lt;/span&gt;&lt;/sub&gt;. The absolute value of t&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i&lt;/span&gt;&lt;/sub&gt; is irrelevant.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is how I believe time should be view in test code, in fact I will postulate a “test of time” at the end of this article.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I will assume that we all agree fragile tests are costly to maintain, and have no place in a regressions suite. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Common misuses of time #1: Validation of time-dependent data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Common misuses of time is validation of messages, dialogs, errors and other strings containing the current time generated by the system under test. I recently saw a test case validating a text containing the latest updated time of a graph. The test would look something like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;graph.Update();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;String&lt;/span&gt; expectedMessage = &lt;span style=&quot;color: #2b91af;&quot;&gt;String&lt;/span&gt;.Format(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Last update: {0}&quot;&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now.TimeOfDay.ToString(&lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;hh\:mm&quot;&lt;/span&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Assert&lt;/span&gt;.AreEqual(graph.StatusMessage, expectedMessage, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Incorrect status message displayed&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;The graph would show a status like ’Last updated: 13:02’. The test would then validate the correctness of this message using the current time. Of course, the problem is if this test is run exactly around 13:02:59 then there is a chance that the time changes to 13:03 between the Update call and the computation of the expected message, causing this test to fail. This is a fragile test. Computing the expected message before updating will not fix this problem. Actually for this test to be ‘correct’ it should validate that the time returned is within the window of possibilities, like: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt; windowStart = &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;graph.Update();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt; windowEnd = &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Assert&lt;/span&gt;.IsTrue(windowStart &amp;lt;= ExtractDateTime(graph.StatusMessage) &amp;lt;= windowEnd, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Incorrect status message displayed&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Although this test is stable with respect to the natural progression of time, it is susceptible to outside factors affecting the system time. It may happen that the system clock is adjusted through synchronizing the system clock with an online server, or due to daylight savings, just before setting windowEnd variable. Of course these examples are much less likely to happen, but if you run 100,000’s of tests every day chances are that you will end up running into strange scenarios with time behaving unpredictable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The correct way is of course to mock the timer in the system under test such that you control it from your test. Then it’s a matter of just freezing time:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;MockTimer&lt;/span&gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;ITimer&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt; currentTime = &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; GetTimeOfDay()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; currentTime;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;With a mock approach the test is directly in control of the time and you rid yourself of external dependencies. The down-side is that the system under test must be architected in a fashion where you can supply your mock timer to it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Perception of time&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Before I go on to the next example I’d like to define perception of time from a computer program.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;By perception of time, I mean the perceived amount of time that one unit of code takes to execute (a unit could be a single instruction, a function call or a class/component performing a task). Perception of time for a computer program is &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;far&lt;/i&gt; from constant. It is affected by a plethora of external factors. The most common is CPU usage (by other processes), a highly stressed CPU will execute your program much slower, effectively causing time dilation (actually the metaphor works well here, the faster the CPU is running the more time slows down &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: Wingdings; mso-ansi-language: EN; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;&quot;&gt;&lt;span style=&quot;mso-char-type: symbol; mso-symbol-font-family: Wingdings;&quot;&gt;J&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;On the microscopic time-scale perception of time is impacted by OS time slots, an instruction could finish in 1 millisecond or a program may have to wait 100 milliseconds for its OS time slot to begin.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;On the macroscopic level the program could be using a database which happens to be in a locked state, causing it to run for 10 minutes before the lock is released and the program is able to finish.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So in fact, the perception of time of a computer program changes quite a lot during execution. It is jittery from time slotting, and in periods it slows or speeds up drastically due to other programs consuming resources.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Common misuses of time #2: ‘Performance’ regression test&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A colleague of mine recently wrote a regression test to prevent a performance issue being reintroduced. The problem simplified was that a function working on a set should run in constant time, because the correct implementation needed only to look at the last element in the set to compute the result. The premise of the test was that running the function on a single element set and measuring the execution time should roughly match a repeat execution on a five element set. If the execution times differed by more than 50% the test would fail:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt; beginSingleElement = &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ExecuteTestOnSingleElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;TimeSpan&lt;/span&gt; durationSingleElement = &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now - beginSingleElement;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt; beginMultipleElements = &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ExecuteTestOnMultipleElements();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;TimeSpan&lt;/span&gt; durationMultipleElements = &lt;span style=&quot;color: #2b91af;&quot;&gt;DateTime&lt;/span&gt;.Now - beginMultipleElements;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;TimeSpan&lt;/span&gt; delta = durationSingleElement - durationMultipleElements;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Assert&lt;/span&gt;.IsTrue(&lt;span style=&quot;color: #2b91af;&quot;&gt;Math&lt;/span&gt;.Abs(delta.Ticks) &amp;lt; 0.5 * durationMultipleElements.Ticks, &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Performance problem detected.&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Okay, fair enough, the test is at least making a comparison between two runs and not measuring absolute time. Also, it is forgiving – it allows for 50% difference in measurements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;However, with our understanding of perception of time, it is clear that this test is susceptible to changes in perception of time. If the computer happens to start installing Windows Updates during the &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;ExecuteTestOnMultipleElements&lt;/span&gt;&lt;span style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; &lt;span lang=&quot;EN&quot;&gt;method call, it could significantly impact the test – even outside the 50% safety-margin!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Again, the test is fragile leading to superfluous analysis work upon failure. In our context we were able to refactor this test to be based on code coverage measurements, which is deterministic and within our control. But the general advice is that performance tests should not be included in regression suites where the purpose is to determine the quality of a particular build. Instead these tests should be executed in a performance suite, which measures the performance of the product running in a highly controllable environment, and where the result is to gauge the performance, not to provide a yes/no on quality.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The ‘test of time’&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt 36pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Mock the underlying timer functions in your test framework the following way:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Initialize a counter to 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 10pt 72pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Every call to your timer function increases this counter by a random positive integer amount and returns the updated value of the counter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Repeatedly run your tests (as well as the system under test) using this mock-implementation of a timer. If any of the tests fail this is an indication that they are not agnostic to the perception of time, and in turn they are susceptible to external factors that can influence the system clock.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This test will surface any undesired test dependencies on the system time, so you are able to fix them up-front. The random pattern makes it much more likely that you will detect problem like #1 and #2.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span lang=&quot;EN&quot; style=&quot;mso-ansi-language: EN;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;span lang=&quot;EN&quot; style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ansi-language: EN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;&quot;&gt;If your tests can’t stand this ‘test of time’ then my claim is that given enough time they will cause you problems. Depending on your setup, it may be more or less critical that you have stable regression tests, but for the most part I find that any fragile test will either be ignored during analysis because it is known to be fragile (then it is worthless, because if it happened to find a bug that would also be ignored), or it will keep appearing on your radar over and over again disrupting your daily rhythm, sucking out effort that could otherwise be spent more productively. At first this might not seem such a big problem, but as your scope starts scaling to maybe 10,000 or 100,000 tests, what seemed a small problem suddenly magnifies to a gigantic time hole which impedes you from moving forward in your daily work.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/3096535403598432435/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/06/can-your-tests-stand-test-of-time.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/3096535403598432435'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/3096535403598432435'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/06/can-your-tests-stand-test-of-time.html' title='Can your tests stand the ‘test of time’?'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-5680000665525365622</id><published>2012-05-30T23:52:00.000-07:00</published><updated>2012-05-30T23:52:27.487-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="multi-threaded"/><category scheme="http://www.blogger.com/atom/ns#" term="parallel"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="scheduler"/><category scheme="http://www.blogger.com/atom/ns#" term="slicing"/><category scheme="http://www.blogger.com/atom/ns#" term="stochastic"/><category scheme="http://www.blogger.com/atom/ns#" term="synchronization"/><category scheme="http://www.blogger.com/atom/ns#" term="thread pool"/><title type='text'>Modeling Multi-Threaded Applications</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So last time we looked a bit at stochastic modeling and I introduced the concept in Spec Explorer for modeling random actions/decisions. The example we looked at was a stochastic counter – which is just a tiny bit contrived. Actually, I can’t think of anywhere I would like to use a stochastic counter. Thus, I want to spent some time modeling a real stochastic example in this post.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A very common use of stochasticity is multi-threading/parallel processing. In a parallel system more than one thread can work on solving a problem at the same time (often running on multiple CPUs at the same time). So why does this have to lead to stochastic systems? – you may ask. The fundamental answer to this question is timing. In a parallel environment, to make full use of system resources, you poll a pool of threads for the next available worker thread. Whichever thread is available is determined by “chance”, because it is impacted by the speed of the executing CPUs, latency of external dependencies (RAM, BUS, network, disk, etc.) which we (usually) cannot control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Consider a fictitious parallel environment with 3 worker threads:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIifLW7i135vpBBn7RnavFbb3GaAlmWRR6-_XY5TYd3bsgmSKGTi-8KOsKciTz0kGTasSL6FuM3_Rq8Rj4Kb1cVpXf6cmeOct2bh97vsB8JEP8CdgKKWlW-wm8K66MnuWe1pNOR8J7tt0N/s1600/Diagram.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIifLW7i135vpBBn7RnavFbb3GaAlmWRR6-_XY5TYd3bsgmSKGTi-8KOsKciTz0kGTasSL6FuM3_Rq8Rj4Kb1cVpXf6cmeOct2bh97vsB8JEP8CdgKKWlW-wm8K66MnuWe1pNOR8J7tt0N/s640/Diagram.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;  &lt;v:stroke joinstyle=&quot;miter&quot;&gt;  &lt;v:formulas&gt;   &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;   &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;   &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;   &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;   &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;  &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;  &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;  &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/span&gt;&lt;/v:shapetype&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This component is used by assigning the Job Scheduler a Job to be processed, then the scheduler will hold this job in its internal queue and await a worker thread to be available, once a thread is available it will take the incoming Job and start processing it in its own execution context (i.e. CPU, RAM, etc.). After successfully processing the Job the worker thread stores the result in an aggregated result list (which has to be thread-safe).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A very common sunshine scenario to test would be to give the Job Scheduler a single Job and check that a worker thread starts working on it and finally check the result from the aggregated result list. &lt;/span&gt;&lt;/div&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Synchronization in models of multi-threaded systems&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Multi-threading is at first a tough concept to grasp, and even those skilled at developing parallel systems, frequently make mistakes. Minor problems magnify significantly in a multi-threaded environment, because they can lead to system deadlocks or sporadic behavior, which is &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;exceptionally&lt;/i&gt; difficult to reproduce and debug. One common problem is to assume that a result is ready, while in fact it is still being process by a worker thread – this is lack of synchronization. For example, in the case of the parallel job scheduler, it is important that we wait for the worker threads to finish processing jobs before we check the results – this may at first seem simple, but actually it is counter-intuitive to be implementing synchronization actions in a model, and also we need to think about how we slice the model to produce only valid models. Consider a model comprising the following three rules:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;ScheduleJob()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;AwaitResults()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;GetResults()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The &lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;ScheduleJob&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; is a stochastic rule that creates a job and schedules it on any worker thread. Furthermore, we need a synchronization action – here named &lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;AwaitResults&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; – to ensure all worker threads have finished. Finally &lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;GetResults&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; checks that the results are correct. A valid slice of this model would look like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; SlicedStochasticWorkerModel() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(ScheduleJob{&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;X&lt;/i&gt;&lt;/b&gt;} ; AwaitResults ; GetResults) || StochasticWorkerModel&lt;span style=&quot;color: green;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This slice composes a model where we schedule &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;X&lt;/i&gt;&lt;/b&gt; jobs, await results and finally check the results are correct. However, from a pure modeling perspective the sequence ( ScheduleJob ; AwaitResults ; ScheduleJob ; GetResults ) is perfectly valid, but in a multi-threaded environment this sequence behaves indeterministic, so we have to constrain our model using slicing. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Parallel job scheduler model&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A simple model of this system with these three rules could look like (see reference [1] for the full sample code):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; Schedule a job in the system for processing&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The id of the selected worker thread.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;ScheduleJob()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ScheduleJobRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; thread = &lt;span style=&quot;color: #2b91af;&quot;&gt;Choice&lt;/span&gt;.Some&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Int32&lt;/span&gt;&amp;gt;(i =&amp;gt; i &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; 3);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;runningJobs.Add(++nextJobId, thread);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; thread;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; Dummy action which causes the model to wait for the worker thread to finish&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; and deliver their results before checking them&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;AwaitResults()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; AwaitResultsRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; Check the results from the worker threads&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;A checksum of the results computed by the threads.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;GetResults()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; GetResultsRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; runningJobs.Keys.Sum();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Where the finite state machine composes a map of which jobs are running on which worker threads. It’s interesting to notice that the synchronization rule is an empty stub – the model does not need to do anything to synchronize, because the model is not multi-threaded, only the system under test is. Synchronization takes place at the slicing level of the model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Exploring this model with a limitation of scheduling a maximum of two jobs yields:&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAG3vuMMBLV9YS4MQNJZbTVwP7PpyT3y16D-x9i2ptGSwLP-mqJOv5KKXRvTawCsdjpIFnuv_0TvZiG-lFD9xl8fU370-9V9YsLgcSFIKL3JNkkPRdQYuiKSnnZTZYLCoTFX__LrpO0bVO/s1600/parallel+jobscheduler+two+jobs.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;290&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAG3vuMMBLV9YS4MQNJZbTVwP7PpyT3y16D-x9i2ptGSwLP-mqJOv5KKXRvTawCsdjpIFnuv_0TvZiG-lFD9xl8fU370-9V9YsLgcSFIKL3JNkkPRdQYuiKSnnZTZYLCoTFX__LrpO0bVO/s640/parallel+jobscheduler+two+jobs.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The top section of the model is where we schedule the two jobs, then we have a synchronization action and finally we check the results.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Parallel job scheduler implementation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The system under test is implemented using a standard .NET &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;ThreadPool&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; to process jobs in parallel.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;StochasticJobScheduler&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; runningJobs = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ScheduleJob()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;runningJobs++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadPool&lt;/span&gt;.SetMaxThreads(3, 3);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadPool&lt;/span&gt;.QueueUserWorkItem(&lt;span style=&quot;color: #2b91af;&quot;&gt;WorkerThread&lt;/span&gt;.Process, runningJobs);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; AwaitResults()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Wait for all threads to complete&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #2b91af;&quot;&gt;AggregatedResultList&lt;/span&gt;.Count() &amp;lt; runningJobs)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Thread&lt;/span&gt;.Sleep(100);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; GetResults()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;AggregatedResultList&lt;/span&gt;.GetResults().Sum();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The job processing is delegated to the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;WorkerThread&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;.Process&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; method. It is very simple to implement a job scheduler like this, but unfortunately we run into some problems while executing the tests. From the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;ScheduleJob&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; implementation it is evident that we do not adhere to the requirements of the model – we always return zero telling the model the first worker thread picked up the job, but in fact we have no way of knowing that. If the results are independent of which thread processed them, then you can argue that it doesn’t matter that we ‘lie’ to the model about which thread got picked up – but then I would counter that argument by asking why we even model it stochastically. Even worse, in cases where the result actually does depend on which thread executes it, we get incorrect results. Observe the following change in the worker processing implementation:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;AggregatedResultList&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;.AddResult(&lt;span style=&quot;color: #2b91af;&quot;&gt;Thread&lt;/span&gt;.CurrentThread.ManagedThreadId);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This will make the thread report its unique ID as the result of the procession and would cause our tests to fail sporadically because we are ‘lying’ to the model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Okay, so let’s fix this properly, we can let the worker thread tell the scheduler the last used thread ID using proper synchronization – I’m not going to include the implementation details here, but I refer you to the sample code for how this is done. The result of this change is effectively that the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;StochasticJobScheduler&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;ScheduleJob&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; method now returns:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;Thread&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;.CurrentThread.ManagedThreadId&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Of the selected worker thread. Unfortunately, what we end up with is the following failure:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt 36pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Expected matching return, found return ScheduleJob()/15. Diagnosis:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;outputs do not match&lt;br /&gt;
comment: checking step &#39;return ScheduleJob/0&#39;&lt;br /&gt;
assert&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;failed: expected &#39;0&#39;, actual &#39;15&#39; (return of ScheduleJob, state S1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;outputs do not match&lt;br /&gt;
comment: checking step &#39;return ScheduleJob/1&#39;&lt;br /&gt;
assert&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;failed: expected &#39;1&#39;, actual &#39;15&#39; (return of ScheduleJob, state S1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 10pt 72pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;3.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;outputs do not match&lt;br /&gt;
comment: checking step &#39;return ScheduleJob/2&#39;&lt;br /&gt;
assert&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;failed: expected &#39;2&#39;, actual &#39;15&#39; (return of ScheduleJob, state S1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;What this is telling us is that the ID of the picked worker thread was 15, which is not one of the expected outputs from the model (they are 0, 1 or 2). This is because we have a mismatch between the expected thread IDs from the model, and the actual IDs supplied by .NET.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In fact the value of 15 is arbitrary, .NET could return anything, as long as the value is unique per thread. What happens is that .NET is hiding the information about which threads were created first, because it is simply not relevant for the implementation of a parallel system using thread pools. In fact, exposing such information could often lead to poorly designed systems, because in a pool of threads the consuming system is supposed to treat all threads as being equal.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We can let the adapter layer translate the .NET IDs to an index between 0 and 2 using the following piece of code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt; threads = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ScheduleJob()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = GetLastThreadId();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!threads.Contains(i))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;threads.Add(i);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; threads.IndexOf(i);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This will make sure we don’t ‘lie’ about which thread was picked, which allows Spec Explorer to detect the correct path taken in the stochastic model at runtime. However, this will still not solve the problem where the results depend on which thread picked up the job.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This leaves us with the final conclusion. For multi-threaded applications, modeling is sort of a double edged sword. At one side, the system should shield away the multi-threaded aspect and from a testing perspective, really we should focus on the overall system behavior, and not model the stochastic choices. On the other hand, we would still like to model the full-blown system, including the stochastic choices, because they tell us something about how well balanced the implementation is. For example, in the case of the parallel job queue, we really would like to make sure, that the work flow is evenly balanced between the threads. Unfortunately, this would require more information than Spec Explorer provides. Currently, Spec Explorer will generate one test case from our model, which models all available paths, but running this test will only provide you with a single sample of how the system reacted to the specific scenario, which does not tell you a lot about the behavior. Instead you need to run the test many times and see that the system is actually taking different branches through the model – which is actually really difficult to see, because Spec Explorer does not do a lot to provide you with meaningful results.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;&quot;&gt;It would be nice if Spec Explorer could visualize which branch was picked by the model, such that you could make a visual inspection of the test path. Where you to repeat the test 1000 times without resetting this visualization, a heat-map of the model would start to emerge, which would be very useful for multi-threaded profiling.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;References&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;  [1] &lt;/span&gt;&lt;a href=&quot;http://www.ge.tt/15jBBRI&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Parallel Scheduler Model&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/5680000665525365622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/05/modeling-multi-threaded-applications.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5680000665525365622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5680000665525365622'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/05/modeling-multi-threaded-applications.html' title='Modeling Multi-Threaded Applications'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIifLW7i135vpBBn7RnavFbb3GaAlmWRR6-_XY5TYd3bsgmSKGTi-8KOsKciTz0kGTasSL6FuM3_Rq8Rj4Kb1cVpXf6cmeOct2bh97vsB8JEP8CdgKKWlW-wm8K66MnuWe1pNOR8J7tt0N/s72-c/Diagram.PNG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-6985980379275461322</id><published>2012-05-10T23:43:00.000-07:00</published><updated>2012-05-10T23:43:09.818-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="choice"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="random"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="stochastic"/><category scheme="http://www.blogger.com/atom/ns#" term="stochastic accumulator"/><title type='text'>Modeling Stochastic Systems in Spec Explorer</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;One of the more advanced – and powerful – features of Spec Explorer is its ability to handle stochastic SUTs. Stochasticity is common in systems with external dependencies, this could for example be the file system, network interface or external devices. Common for all these dependencies is that they sometimes fail for various reasons. You cannot predict when this will happen, and for the most part in Software testing we strive to avoid these spurious behaviors at all cost.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Another source of stochasticity is the use of random in the SUT (which I will explore a bit more in this post) or stochastic behavior due to race-conditions in multi-threaded applications (which I will investigate further in a later post).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;First of all, what does a stochastic model look like? Take a look here:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxyfCpYQrr_-XoVofIbKp_6-4-re1BFTzje3GeF3M4_uymPQnVKcWPjtKyeZHf9-RB9zpPWeJ7NRgHFRFSeUJIEyLOJTmpa6bII0ScOf-7c-0wgeBoq8DvApQR6geR88xA0ZUz_JQEpQZR/s1600/stochastic+double+add+model.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxyfCpYQrr_-XoVofIbKp_6-4-re1BFTzje3GeF3M4_uymPQnVKcWPjtKyeZHf9-RB9zpPWeJ7NRgHFRFSeUJIEyLOJTmpa6bII0ScOf-7c-0wgeBoq8DvApQR6geR88xA0ZUz_JQEpQZR/s400/stochastic+double+add+model.JPG&quot; width=&quot;383&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;  &lt;v:stroke joinstyle=&quot;miter&quot;&gt;  &lt;v:formulas&gt;   &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;   &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;   &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;   &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;   &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;  &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;  &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;  &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/span&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This picture represents a model of a stochastic accumulator. It shows a slice where the accumulator is increased twice then reset. Each addition is stochastic in that it can add either 1 or 2 to the counter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;When working with stochastic models, in addition to the normal “round” states, Spec Explorer introduces diamond-shaped decision states. Each diamond represents a choice in the model where the SUT can behave in one of many ways. In the case of the stochastic accumulator we can see that the value of the accumulator can go from the initial value of 0 to either 1 or 2 in the first addition step.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Making choices in stochastic models&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The fundamental component of stochastic modeling is the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;Choice&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; class. This class provides an interface to generate a random choice in Spec Explorer. The following illustrates how to use it to choose a random &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;enum&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; value:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;StochasticAction&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;A,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;B&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;switch&lt;/span&gt; (&lt;span style=&quot;color: #2b91af;&quot;&gt;Choice&lt;/span&gt;.Some&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;StochasticAction&lt;/span&gt;&amp;gt;())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;StochasticAction&lt;/span&gt;.A:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;StochasticAction&lt;/span&gt;.B:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So why not use Random directly in the model?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Add()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; Random_AddRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; v = 1 + random.Next(2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;counter += v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Well – if you do that, Spec Explorer will not know that the action is stochastic, and the outcome model will be a single random sample of the full stochastic model, which will vary when you re-explore the model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDVv1UNunlHdDwnGT-M_ahLaETGT6JdbRIFQzuV9YYcUjB8nkQ7vZHZT4oRaV9KqlwfaOdfdMXEKLnGMjNdc4GRt1vUb7oue4a0QFptbnpmYHTLDpQ9tMzZGRxCoCejG6Cupnfj2Dgrw0H/s1600/random+sample+model.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDVv1UNunlHdDwnGT-M_ahLaETGT6JdbRIFQzuV9YYcUjB8nkQ7vZHZT4oRaV9KqlwfaOdfdMXEKLnGMjNdc4GRt1vUb7oue4a0QFptbnpmYHTLDpQ9tMzZGRxCoCejG6Cupnfj2Dgrw0H/s320/random+sample+model.JPG&quot; width=&quot;149&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Instead, using the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;Choice&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; class will make Spec Explorer aware that the action is stochastic and it will understand that there are different outcomes:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Add()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; Choice_AddRule()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; v = &lt;span style=&quot;color: #2b91af;&quot;&gt;Choice&lt;/span&gt;.Some&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;((i) =&amp;gt; i &amp;gt; 0 &amp;amp;&amp;amp; i &amp;lt; 3);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;counter += v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This will produce the stochastic model depicted in the top of the post.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Generating tests from stochastic models&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;When generating test cases from a stochastic model you need to set the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;AllowUndeterminedCoverage = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; flag for the construct:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; StochasticTestSuite() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;, TestEnabled = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;construct&lt;/span&gt; test cases &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; strategy = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;ShortTests&quot;&lt;/span&gt;, AllowUndeterminedCoverage = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; SlicedStochasticModelProgram()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The generated tests are no longer scenarios like we are used to, but they become graphs themselves, visualizing how the test can go down different paths based on the stochastic behavior of the SUT:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBwQhqXHE46TAgN3a2-MFHZQc6bltxBpB3-BASbenQP1vMIu75ErNz1n58lso_WVtJtXAts2O7w4AQ8yIk4cJMeFrz_Si_YCjeslxerye9NLT3zBD3_DV3HXWsxx4VsNyHA8itSvemMIbG/s1600/stochastic+double+add+test.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;342&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBwQhqXHE46TAgN3a2-MFHZQc6bltxBpB3-BASbenQP1vMIu75ErNz1n58lso_WVtJtXAts2O7w4AQ8yIk4cJMeFrz_Si_YCjeslxerye9NLT3zBD3_DV3HXWsxx4VsNyHA8itSvemMIbG/s400/stochastic+double+add+test.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The test will start out in the initial state 0. Then it will call Add. Depending on the return value of the Add call it will either dive deeper into the left path (if Add returned 1) or right path (Add returned 2). Test exploration will then continue from whatever state it reached after the stochastic Add action.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;An obvious question to ask is – why does some of the stochastic actions merge back into existing branches, while others go to new branches, even though the states are the same? It turns out, there is a nice switch which will clean this up:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;switch&lt;/span&gt; EnableExplorationCleanup = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The resulting test graph then looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6mHh1jvD0nsD__qlZdqt0Yj7YXZiAVv7GUNGNxTDgFwAjoxcbOmaxD81_f40xnLlWhZvYDVspwiaH9OX0CEX2YnLl49yH84lBB4SwSMjLVbd6GUZC31df47X3cyh42tkVwN25yQHHcWbi/s1600/stochastic+double+add+test+cleaned+up.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6mHh1jvD0nsD__qlZdqt0Yj7YXZiAVv7GUNGNxTDgFwAjoxcbOmaxD81_f40xnLlWhZvYDVspwiaH9OX0CEX2YnLl49yH84lBB4SwSMjLVbd6GUZC31df47X3cyh42tkVwN25yQHHcWbi/s400/stochastic+double+add+test+cleaned+up.JPG&quot; width=&quot;383&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Which is nice – but come on guys, why do I need to manually set a switch to produce a cleaned-up graph?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Auto-generated test code from stochastic models&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;While the feature is very powerful and a lot of effort has been put into the visualization, such that the decision points in the models are clear, the generated test code lacks the same polish. I’m aware that it is auto-generated, and you don’t put as much attention into it. But when you get to the point that one of your test cases fails and you need to debug what went wrong, having high quality test code helps a lot in the debugging effort. Unfortunately, high quality is not a word I would use about the generated test code. It is _littered_ with labels and goto statements, nested blocks inside yet more nested blocks, and finally dummy exception like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;InvalidOperationException&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;never reached&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;thrown at multiple places in the code. This looks like a part of the product that could use some attention…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;It’s a good thing it’s hidden away for the most part, and the verbosity of the test is quite good. For example if the SUT does not behave according to one of the modeled behaviors the following error is raised:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 28.5pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;expected matching return, found return Add()/0. Diagnosis:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 46.5pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;outputs do not match&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 64.5pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;comment: checking step &#39;return Add/2&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 64.5pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;assert&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;failed: expected &#39;2&#39;, actual &#39;0&#39; (return of Add, state S1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 46.5pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.&lt;/span&gt;&lt;/em&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;outputs do not match&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 64.5pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;comment: checking step &#39;return Add/1&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt 64.5pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;assert&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp; &lt;/span&gt;failed: expected &#39;1&#39;, actual &#39;0&#39; (return of Add, state S1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;which is fairly descriptive. In this case the Add method returned 0, but it is only expected by the model to return either 1 or 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Uniqueness of action labels in stochastic models&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In the above model for a stochastic accumulator, the Add action returns the value that was added to the counter. From a modeling perspective, this information is irrelevant, because I can simply inspect the counter and observe the change – actually it’s perfectly fine to do just that for a model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX6Dzy3gxFHIQQIcltrLuWxDDYA7Ul4W9-wwXZ_i5FQPDc551EnGZv_QV7VpmIJ2J1ewCspF_B2_WGLUCwEWe_nVzLd9pUFGW8Pek3BZIujfgqXSoMl1ER_CJsHOrP-f3WFLyGHBZSGhrp/s1600/stochastic+double+add+model+void+add.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX6Dzy3gxFHIQQIcltrLuWxDDYA7Ul4W9-wwXZ_i5FQPDc551EnGZv_QV7VpmIJ2J1ewCspF_B2_WGLUCwEWe_nVzLd9pUFGW8Pek3BZIujfgqXSoMl1ER_CJsHOrP-f3WFLyGHBZSGhrp/s400/stochastic+double+add+model+void+add.JPG&quot; width=&quot;380&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;If you compare to the model on the top of the post, the only difference is that Add does not reveal what value was added. This works for the model, but once you go into exploring test cases, Spec Explorer will complain with the following error:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Block(Restriction of exploration: some kinds of composite behaviors (including test cases construct,&lt;br /&gt;
requirement coverage construct, etc.) won&#39;t work when inner behavior has any state which has outgoing&lt;br /&gt;
steps with exactly the same label. If so, try adjusting your model to avoid it and re-explore.) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The essence of this convoluted error message is that “any state which has outgoing steps with exactly the same label” is prohibited. You can think of the return value of a stochastic action as a checkmark for Spec Explorer to determine which branch the SUT actually took during run-time test execution. This implies that the return values for a given action must be unique, otherwise Spec Explorer would not be able to tell exactly which path was followed. This furthermore puts a constraint on the SUT, as the SUT (or adapter) must reveal which path the SUT took run-time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is not always possible if you are doing black-box testing, for some SUTs the stochastic choices may be hidden from the outside by the design of the system. In these cases it is up to the adapter layer to probe the SUT after a stochastic choice was made to determine which test-branch the SUT followed. Normally the effect of a stochastic choice is measurable in the state of the SUT, but in rare cases the effect may be invisible to the outside, and only affect later decisions. If this is the case, then you will not be able to determine the run-time test-branch before later in the test case, which means you cannot satisfy Spec Explorers condition on unique labels. A way around this though, is to make a coarser granularity action that consolidates all of the actions required for you to determine the stochastic choice made in the first action.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In more exotic cases, the behavior of the SUT could be affected by some truly random physical effect. Here we are out of luck, as measuring the random effect is likely to affect the outcome of the decision.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;&quot;&gt;[1] &lt;a href=&quot;http://www.ge.tt/1vGHKWH&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Stochastic Accumulator Model&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/6985980379275461322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/05/modeling-stochastic-systems-in-spec.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/6985980379275461322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/6985980379275461322'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/05/modeling-stochastic-systems-in-spec.html' title='Modeling Stochastic Systems in Spec Explorer'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxyfCpYQrr_-XoVofIbKp_6-4-re1BFTzje3GeF3M4_uymPQnVKcWPjtKyeZHf9-RB9zpPWeJ7NRgHFRFSeUJIEyLOJTmpa6bII0ScOf-7c-0wgeBoq8DvApQR6geR88xA0ZUz_JQEpQZR/s72-c/stochastic+double+add+model.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-5627343300385307930</id><published>2012-03-29T05:12:00.000-07:00</published><updated>2012-03-29T05:12:34.666-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="abstraction level"/><category scheme="http://www.blogger.com/atom/ns#" term="code coverage"/><category scheme="http://www.blogger.com/atom/ns#" term="collateral code coverage"/><category scheme="http://www.blogger.com/atom/ns#" term="combinatorial model"/><category scheme="http://www.blogger.com/atom/ns#" term="fuzzy model"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="ramifications"/><title type='text'>Collateral code coverage, ramifications on Model-Based Testing</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;My relationship to code coverage is one of love and hate. I &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;love&lt;/i&gt; code coverage because it’s a quantitative metric which tells you something about the relation between your tests suites and your product code. I &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;hate&lt;/i&gt; code coverage because it must be the most widely abused metric in software testing. For more on this check my previous post on ‘&lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2011/05/application-of-code-coverage-to-model.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Application of Code Coverage to Model Based Testing&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;’&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So why is code coverage so bad? There seems to be a strong drive from management to reach high coverage numbers (which is great, it reduces the risk of having test holes). But then it’s often related to the quality of the product – almost as the only metric of quality. The critical problem with this approach is that code coverage tells you nothing about whether the code is correct or not – only that it was exercised.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Let me coin a new term here: &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Collateral code coverage&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Definition: Additional code coverage from executing a test compared to the minimum possible code coverage required to validate the behavior being tested. In other words, the amount of code coverage where the &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;result&lt;/b&gt; of exercising that code is never verified by the test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Let me illustrate by an example. Consider a small program that converts an input value in kilometers to miles. The program consists of a Windows form application that calls a class library component that converts the value and displays it on the form. Say we want to test that this sample application converts the input value 1 km correctly to 0.62 miles we may develop a unit test that calls the class library directly with the input value and output values:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;TestMethod&lt;/span&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TestConversionOfKilometersToMiles()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Assert&lt;/span&gt;.AreEqual(0.62, &lt;span style=&quot;color: #2b91af;&quot;&gt;Converter&lt;/span&gt;.KilometersToMiles(1));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;But it’s equally common to use a UI based test framework which enters the value and presses the convert button and then reads the computed value from the output field (equally common, but extremely more complex…), which could look like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;TestMethod&lt;/span&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TestConversionOfKilometersToMiles()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Form&lt;/span&gt;.Kilometer.SetValue(1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Form&lt;/span&gt;.ConvertButton.Click();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Assert&lt;/span&gt;.AreEqual(0.62, &lt;span style=&quot;color: #2b91af;&quot;&gt;Form&lt;/span&gt;.Miles.GetValue&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;decimal&lt;/span&gt;&amp;gt;());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The tests have the same purpose and the same level of validation, but the UI based test will cover considerably more code than the unit test. Since the purpose of both tests is simply to validate that the converted value is correct, the additional coverage from using the UI based approach is considered collateral.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Collateral code coverage is common. It can come from unintentional code coverage (test defects causing it to execute unpredicted code branches) or coverage that is intentionally not verified. Very often tests cases are designed to execute a scenario and then validate a single outcome. The longer the scenario the more code will be covered, but the level of validation remains the same. In some extreme cases we see test cases that cover thousands of code lines but still only contain one validation. These tests obviously have high collateral code coverage. You may argue they are poorly designed tests (and I would agree), but the problem exists for almost any size scenario (maybe excluding unit tests, depending on your definition of a unit).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In general the higher the abstraction level of the test the more collateral code coverage it generates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Collateral code coverage is unavoidable and has the unfortunate side-effect of artificially inflating confidence in the product, which is why code coverage is a poor metric for product quality.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;&quot;&gt;Ramifications on Model-Based Testing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;But this is a blog about Model-Based Testing, so what are the ramifications of collateral code coverage on MBT?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In general MBT seems to be at an even higher abstraction level than scenario based tests, thus it should be even worse with respect to collateral code coverage. In many cases I find that this is true, MBTs from my experience usually have lots of collateral code coverage, which is a deficit. But MBT is a very broad concept, and in cases where MBT is used for generating input/output values for an API, this is not necessarily the case (see for example my posts on the Traveling Salesman Problem).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To enumerate a few model types and their ramification:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: currentColor; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: 0;&quot;&gt;   &lt;td style=&quot;background-color: transparent; border: 1pt solid windowtext; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 133pt;&quot; valign=&quot;top&quot; width=&quot;177&quot;&gt;   &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;UI/Data Flow Model&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background-color: transparent; border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 376.4pt;&quot; valign=&quot;top&quot; width=&quot;502&quot;&gt;   &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;High-abstracting model that mimics the behavior of data moving in a   system under test. These models tend to have high collateral code coverage   because they mimic user scenarios&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 1;&quot;&gt;   &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 133pt;&quot; valign=&quot;top&quot; width=&quot;177&quot;&gt;   &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Combinatorial Model&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 376.4pt;&quot; valign=&quot;top&quot; width=&quot;502&quot;&gt;   &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Low-abstraction model that feeds different combinations of input into   a single unit under test. The additional collateral code coverage per generated   test is normally low. However, they can have a constant overhead from setting   up the execution environment, depending on how tightly they interface with   the unit under test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 133pt;&quot; valign=&quot;top&quot; width=&quot;177&quot;&gt;   &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Fuzzy Model&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 376.4pt;&quot; valign=&quot;top&quot; width=&quot;502&quot;&gt;   &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Low-abstraction model that produces random sequences of input to a   system for stress testing and security testing. Usually the goal is to crash   the system under test, and no functional validation is performed. The   objective of these models is to branch out and hit as much code as possible. These   models generate fully collateral code coverage.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;&quot;&gt;By all means this is not nail in the coffin for MBT, but it emphasizes the need for clever models along with a careful disclaimer when you rely on code coverage data from MBTs. For example using code coverage obtained from fuzzy modeling would be a horrible metric for product quality (unless you just care about not crashing).&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/5627343300385307930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/03/collateral-code-coverage-ramifications.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5627343300385307930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5627343300385307930'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/03/collateral-code-coverage-ramifications.html' title='Collateral code coverage, ramifications on Model-Based Testing'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-2456493040293820286</id><published>2012-03-23T02:19:00.000-07:00</published><updated>2012-03-23T02:19:28.759-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="complex type"/><category scheme="http://www.blogger.com/atom/ns#" term="constraint"/><category scheme="http://www.blogger.com/atom/ns#" term="containers"/><category scheme="http://www.blogger.com/atom/ns#" term="immutable"/><category scheme="http://www.blogger.com/atom/ns#" term="lifting"/><category scheme="http://www.blogger.com/atom/ns#" term="magic rule"/><category scheme="http://www.blogger.com/atom/ns#" term="model"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="SetContainer"/><category scheme="http://www.blogger.com/atom/ns#" term="struct"/><title type='text'>Complex types in immutable containers and ‘magic rules’ – TSM Part III</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;In &lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2012/02/re-modeling-traveling-salesman-part-ii.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;part II&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; we saw one approach to optimize the growing algorithm by using a more intelligent concept for extending graphs, than the brute force way of &lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2012/02/modeling-traveling-salesman.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;part I&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;  &lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;With the new approach implemented we can now lift our restriction on the input domain size. Effectively there is no need for constraining the grid domain when the algorithm works on the edges instead of grid input combinations.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The original implementation converted vertices and edges into integer representations (using index = y*size + x), but this approach is no longer applicable when the input domain is unbounded. The first step in fixing this is to refactor the model to store vertices and edges as &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;structs&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; instead:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, y;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; VertexData(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.x = x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.y = y;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;struct&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;EdgeData&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt; v1, v2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; EdgeData(&lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt; from, &lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt; to)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.v1 = from;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.v2 = to;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;SetContainer&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; can take a &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, such that our definition of active vertices in the model changes to:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;SetContainer&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt;&amp;gt; vertices = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;SetContainer&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Because &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;structs&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; are simple data structures instead of object the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;SetContainer&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; will correctly identify permutations of the same sequence as being equivalent, whereas had we used the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;Vertex &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;class directly, the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;SetContainer&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; would be storing object references instead of the object data and sequence would matter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;This trick works in general, if you want to use objects in your immutable containers then wrap the data of the class into a &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;and store that in the containers, then you can easily reconstruct your object from the stored data by overwriting the objects internal data variable in a constructor. Here is my implementation of a &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;Vertex&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; class based on this approach:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Vertex&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt; v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; X { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; v.x; } &lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt; { v.x = &lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt;; } }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; Y { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; v.y; } &lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt; { v.y = &lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt;; } }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; Vertex(&lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt; vertex)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;v = vertex;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Having taken care of the representation, there is one problem left to tackle with this refactoring. The optimized algorithm uses the concept of splicing edges. The problem is that my adapter does not know of edges – it knows only of the vertices that were added. In the original implementation it was possible to pass on the integer representation of the edge being spliced to the adapter and then reconstruct the edge, but this was a bad hack. Because we lifted the domain size constraint this approach no longer works as there is no way to represent an edge as an integer. Also you could argue that the adapter should not even care about the concept of edges, it needs only to build a set of vertices and then let the TSP solver do the rest. Conceptually we don’t want the adapter to know of the edges because then we could cheat in the implementation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Essentially the problem boils down to the fact that the model has a rule that does some magic computations which translate into the addition of a vertex to the graph (the growth process):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Magic()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Magic()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Compute a new vertex using some magic rules&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Vertex&lt;/span&gt; v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Re-use existing concept for adding a vertex to the graph&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;InsertVertex(v.x, v.y);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;InsertVertex(x,y)&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; InsertVertex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We don’t want the adapter nor the SUT to know of this magic rule, because it would have to re-implement the same logic to produce the actual added vertex (the generated tests will call &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;Magic&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; on the adapter, not followed by any call to &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;InsertVertex&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;). So how do we avoid this?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Well… one trick is to use the following pattern:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;VertexData&lt;/span&gt; magicVertex;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Magic()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Magic()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Compute a new vertex using some magic rules&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Vertex&lt;/span&gt; v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Store computed vertex for insertion&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;magicVertex = v.v;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;InsertMagicVertex(x,y)&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; InsertMagicVertex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(x == magicVertex.x);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(y == magicVertex.y);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;InsertVertex(v.x, v.y);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The trick here is that the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;Magic&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; rule computes the vertex, but instead of adding it directly it stores the required information in a variable priming the model. Then the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;InsertMagicVertex&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; rule can pick up the computed value and insert it. Because the signature of this rule has all the required information the adapter layer will simply call the same function as &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;InsertVertex&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; does, with no need for re-implementing the difficult computational logic.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In the Config.cord file, instead of using the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;Magic&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; and &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;InsertMagicVertex&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; rules directly, define the following scenario:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; MagicScenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Magic ; InsertMagicVertex&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This will make sure that after computing a vertex it is immediately added to the graph.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/2456493040293820286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/03/complex-types-in-immutable-containers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/2456493040293820286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/2456493040293820286'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/03/complex-types-in-immutable-containers.html' title='Complex types in immutable containers and ‘magic rules’ – TSM Part III'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-7816743656477485778</id><published>2012-02-26T06:21:00.002-08:00</published><updated>2012-03-05T09:08:04.956-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="graph"/><category scheme="http://www.blogger.com/atom/ns#" term="growing"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="slicing"/><category scheme="http://www.blogger.com/atom/ns#" term="traveling salesman"/><title type='text'>Re-Modeling the Traveling Salesman – Part II</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2012/02/modeling-traveling-salesman.html&quot; target=&quot;_blank&quot;&gt;Last time&lt;/a&gt; we had a look at a very crude model for growing graphs for the Travelling Salesman Problem (TSP). I neglected to actually visualize what the solutions looked like, so here is a rendering of a couple:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMLxLkxFoEPhC-VmUYY_lm0Hz1veD42kCBsWiVQokpub2f43eDaauKlLf2DGXS6PYlCU4hCnxxWkJYfxwdhbFdeMVdBWBNWvYka0KXN0XrxfHPuZHDDwzJmGJh7Z_syUfGHOrqjtwSU31E/s1600/small-graphs.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;184&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMLxLkxFoEPhC-VmUYY_lm0Hz1veD42kCBsWiVQokpub2f43eDaauKlLf2DGXS6PYlCU4hCnxxWkJYfxwdhbFdeMVdBWBNWvYka0KXN0XrxfHPuZHDDwzJmGJh7Z_syUfGHOrqjtwSU31E/s640/small-graphs.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Not very complex indeed... So what seems to be the problem here? Well, the model itself is very exhaustive, so it will generate any conceivable graph on the input domain. The single model rule is generic on the full input domain:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Grid20x20: Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TravelingSalesman.InsertVertex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..19}, y &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..19};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This means that for each state Spec Explorer will try X * Y rules, so for larger input domains like 20x20, it takes forever to explore a state fully. What we are interested in with the TSP is not to construct a plethora of simple graphs, but to generate high complexity graphs (because they are much harder to solve). So what we need is a depth-first search (DFS), luckily Spec Explorer allows us to do just that using a config switch:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;switch&lt;/span&gt; DepthFirst = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Unfortunately it turns out that the DFS exploration uses an “optimized” version of DFS, causing it to always fully explore each state it visits, instead of immediately exploring from newly discovered states. Not that it’s going to show the extra states that got explored, they are simply hidden away until they get fully explored much later in the process (sorry, guys but that’s just silly). Anyway, that is exactly what we wanted to avoid, because even when using DFS exploration on a 10x10 grid it will take hours to generate graphs with 10 vertices.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;The combination of a large input domain coupled with the design of the exploration engine of Spec Explorer, makes it infeasible to find larger graphs this way.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Let’s investigate a different approach. The underlying problem is that we are giving the model too much freedom. Instead of allowing it to add a vertex at any grid point, we can turn the picture around, and instead model the splicing of an edge directly. The process goes like follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;a)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Select any existing edge&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;b)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Splice it by two parameters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;a.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Alpha determines where to insert a splicing point along the edge&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;b.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Beta determines the perpendicular distance from the splicing point to the new point&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;c)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Take the nearest grid point to the decimal point&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 10pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;d)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Grow the graph by trying to insert a vertex at that point&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhulsSwLZrCu_etEzIcg9lu6eLxqORkPCNr2YPaRK00sSoJ7I20b0gu3Q3PUdTkqenPeAA2v3DWHkMzkPwvX20_s4FjubQVH8LwllJMAUqtaXERNVy6MHAGZI8l0upr-9rLqA2QDcRCzuvV/s1600/alpha-beta-splicing.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhulsSwLZrCu_etEzIcg9lu6eLxqORkPCNr2YPaRK00sSoJ7I20b0gu3Q3PUdTkqenPeAA2v3DWHkMzkPwvX20_s4FjubQVH8LwllJMAUqtaXERNVy6MHAGZI8l0upr-9rLqA2QDcRCzuvV/s400/alpha-beta-splicing.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The implementation of splicing goes as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Edge&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Vertex&lt;/span&gt; P1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Vertex&lt;/span&gt; P2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Vertex&lt;/span&gt; Splice(&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; alpha, &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; beta)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Find splicing point&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; spx = (P1.X + P2.X) * alpha;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; spy = (P1.Y + P2.Y) * alpha;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Project perpendicularly&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; ex = -(P2.Y - P1.Y);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; ey = P2.X - P1.X;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; px = spx + beta * ex;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; py = spy + beta * ey;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Vertex&lt;/span&gt;((&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #2b91af;&quot;&gt;Math&lt;/span&gt;.Round(px), (&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)&lt;span style=&quot;color: #2b91af;&quot;&gt;Math&lt;/span&gt;.Round(py));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The signature of the model rule looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TravelingSalesman.SpliceEdge(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; index, &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; alpha, &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; beta);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A clear benefit of this implementation is that the complexity of the rule is independent on the grid size, thus we can extend our grid to be very large and still be able to explore the full state-space within reasonable time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A down-side is that now we have an infinite number of possible inputs on the alpha and beta variables, but we can fix those in the configuration.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Of course, just using the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;SpliceEdge&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; rule will not work, because we require one edge to start with, but we can easily construct an initial edge using our &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;InsertVertex&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; rule. Thus the machine we explore looks like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; FixedTriangle() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;InsertVertex(3,3) ; InsertVertex(16,7) ; InsertVertex(8,16)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Splicing() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(FixedTriangle ; SpliceEdge(_,0.5,0.35)* ; Solve) || TravelingSalesManModel&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice how this machine obtains the desired result using model slicing, to both limit the input domain for &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;SpliceEdge&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; as well as construct a fixed starting triangle to splice from. The starting triangle looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZzsbGKl2pXkGAdvZJ-NVKoN4Irn5HcNWD5HCFjFJUIoaz7CYellRUVF8JzO6-LUk6gg45FbsYh6bso3gYcRPzF4_vubdk_uBoRWU3CUowlJcTyxmyB0RYO2KUwq6VTDutyj3C3CiJi0oy/s1600/graphTriangleTestSuiteS0.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZzsbGKl2pXkGAdvZJ-NVKoN4Irn5HcNWD5HCFjFJUIoaz7CYellRUVF8JzO6-LUk6gg45FbsYh6bso3gYcRPzF4_vubdk_uBoRWU3CUowlJcTyxmyB0RYO2KUwq6VTDutyj3C3CiJi0oy/s320/graphTriangleTestSuiteS0.bmp&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt; text-align: center;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Exploring this on a 20x20 grid yields:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlpX9DRN3DNRiG7syZ8HqRVDgXPj-_XgWAT_b6DxjNJiSdNRpPbwzYwlkwy8EmRvDTNdm71A393tNzVzr1luicviKkYnK7J6Uxy9w4iYBbR7Ip1cUzkNiHA_tMzLGzvPYFydUuwwYltEIm/s1600/splicing-20x20-triangle.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;114&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlpX9DRN3DNRiG7syZ8HqRVDgXPj-_XgWAT_b6DxjNJiSdNRpPbwzYwlkwy8EmRvDTNdm71A393tNzVzr1luicviKkYnK7J6Uxy9w4iYBbR7Ip1cUzkNiHA_tMzLGzvPYFydUuwwYltEIm/s640/splicing-20x20-triangle.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Using this approach we can easily generate graphs containing 10 vertices. A subset of the constructed graphs can be seen here (the starting triangle is shown in gray):&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJY1lIXh8KFLsITGga11I7xsSJ9w-ifVk8CLK4FMRBK7aTw6Ehj_AcWix8KQVRu0B3_l231s_LFL1fmqkKElhGR1z7Nt3rQt9RkxRUcnRogEb-pTNE8jkJmKDkwZJIqA_uUjRrDb_BHZ8m/s1600/10point-graphs.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;219&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJY1lIXh8KFLsITGga11I7xsSJ9w-ifVk8CLK4FMRBK7aTw6Ehj_AcWix8KQVRu0B3_l231s_LFL1fmqkKElhGR1z7Nt3rQt9RkxRUcnRogEb-pTNE8jkJmKDkwZJIqA_uUjRrDb_BHZ8m/s640/10point-graphs.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Some interesting things can be seen from these graphs. Only two of the edges are ever spliced, the left-most edge cannot be spliced as the resulting vertex is invalid under the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;InsertVertex&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; rule. Also, the top-most edge is always spliced in-wards, whereas the right-most edge is spliced out-wards. The first problem stems from the magnitude of the &lt;/span&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; parameter which is too large to produce valid slices, it would be beneficial to vary the magnitude of the input value. The second problem is that &lt;/span&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; &amp;gt; 0, thus the algorithm will always splice in a fixed direction, again we should allow negative values as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Lifting our first limitation we allow &lt;/span&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; to be either 0.35 or -0.35:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Config20x20: Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TravelingSalesman.InsertVertex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..19}, y &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..19};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TravelingSalesman.SpliceEdge(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; index, &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; alpha, &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; beta)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; alpha &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0.5}, beta &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0.35,-0.35};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;And using the following machine definition:&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt; line-height: 115%;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Splicing() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(FixedTriangle ; SpliceEdge(_,0.5,_){2} ; Solve) || TravelingSalesManModel&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We generate much more diverse graphs:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhogiTY_sxHyULQwrX1vmh-mJVQdx04zvf373y6v7Ewdr7mIRHC_KxHDFjkaumuCrlsovqUSLPyrlIY6J1frv2OEPOyjI9ODhToYUJ9g2WQNYb-f25zkT9IHDKv-XLE6RHHZ-6vyG5YjxaZ/s1600/beta-positive-negative-graphs.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;428&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhogiTY_sxHyULQwrX1vmh-mJVQdx04zvf373y6v7Ewdr7mIRHC_KxHDFjkaumuCrlsovqUSLPyrlIY6J1frv2OEPOyjI9ODhToYUJ9g2WQNYb-f25zkT9IHDKv-XLE6RHHZ-6vyG5YjxaZ/s640/beta-positive-negative-graphs.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is already much better! Let’s see how far we can drive this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtuWTvFc2zVj5Fj1LP2-1_nHpIgR3cszxJAOayKh92mMuwdLsJHmvEWrFGV4npVDbPpSm7bRf18onehhMc_flNY0z8bA0UCtGouWCHaYpaIJjEhvJ3t5H3kyU0Arivfsa0q_iN6T0hUTtv/s1600/beta-positive-negative-16vertex-graph.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtuWTvFc2zVj5Fj1LP2-1_nHpIgR3cszxJAOayKh92mMuwdLsJHmvEWrFGV4npVDbPpSm7bRf18onehhMc_flNY0z8bA0UCtGouWCHaYpaIJjEhvJ3t5H3kyU0Arivfsa0q_iN6T0hUTtv/s640/beta-positive-negative-16vertex-graph.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is a partial explore using DFS on the machine. The produced graphs have up to 16 vertices in them:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtbKciFZDg3iuVcQzi8TJex0rXnGRzVK_jgS8KbGYDSKkxmLQTOprrZnb1sn5yMohTS68SVuPUpka8xvcc-enDpwoDn2987i9V8mBmwoGidru7ufuVZlSMmyAZ5DnYSt2Y9wcgIZZXapk9/s1600/graphSplicingTestSuiteS0.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtbKciFZDg3iuVcQzi8TJex0rXnGRzVK_jgS8KbGYDSKkxmLQTOprrZnb1sn5yMohTS68SVuPUpka8xvcc-enDpwoDn2987i9V8mBmwoGidru7ufuVZlSMmyAZ5DnYSt2Y9wcgIZZXapk9/s320/graphSplicingTestSuiteS0.bmp&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt; text-align: center;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;One short-fall of this approach is that the model splices the edges into finer and finer pieces without adding much complexity to the graph. The problem arises when we get close to the boundaries of the grid, and when the rounding of the computed point causes it to snap back on the edge that we are splicing. Of course, we can lift this constraint by expanding the size of the grid, but another approach could be to work on having a floating-point value grid, which we will explore in the next post, where I still owe you the proof for the splicing algorithm.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We saw how the design of Spec Explorer makes it infeasible to grow our original implementation to larger size grids because the number of valid inputs for any given state grows with the number of grid points. This limitation was lifted by changing the model to start out from three fixed points (using model slicing) and then expanding it by splicing only existing edges. The number of inputs using this approach grows by one for each successful model rule. We were able to generate graphs of higher complexity with this approach within reasonable time (minutes).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;[1] &lt;a href=&quot;http://w760768.open.ge.tt/1/files/2UkpCbE/0/blob?download&quot; target=&quot;_blank&quot;&gt;Traveling Salesman Re-model&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/7816743656477485778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/02/re-modeling-traveling-salesman-part-ii.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/7816743656477485778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/7816743656477485778'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/02/re-modeling-traveling-salesman-part-ii.html' title='Re-Modeling the Traveling Salesman – Part II'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMLxLkxFoEPhC-VmUYY_lm0Hz1veD42kCBsWiVQokpub2f43eDaauKlLf2DGXS6PYlCU4hCnxxWkJYfxwdhbFdeMVdBWBNWvYka0KXN0XrxfHPuZHDDwzJmGJh7Z_syUfGHOrqjtwSU31E/s72-c/small-graphs.PNG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-6590194317907909122</id><published>2012-02-14T06:28:00.001-08:00</published><updated>2012-02-14T06:29:13.159-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="combinatorics"/><category scheme="http://www.blogger.com/atom/ns#" term="cycle"/><category scheme="http://www.blogger.com/atom/ns#" term="graph"/><category scheme="http://www.blogger.com/atom/ns#" term="growing"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="NP-hard"/><category scheme="http://www.blogger.com/atom/ns#" term="optimization"/><category scheme="http://www.blogger.com/atom/ns#" term="path"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="slicing"/><category scheme="http://www.blogger.com/atom/ns#" term="tour"/><category scheme="http://www.blogger.com/atom/ns#" term="traveling salesman"/><title type='text'>Modeling the Traveling Salesman</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I’m going to attack a well-known problem from the 1800 century in this post: &lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Travelling_salesman_problem&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Traveling Salesman Problem&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; (TSP).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The objective in the traveling salesman problem is to find the shortest path through a network graph visiting every node/vertex exactly once and returning to the origin, such a path is called a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;tour&lt;/i&gt; of the graph (or a Hamiltonian cycle if you are into computer science). The problem is NP-hard to solve, meaning it is likely that no feasible exact solution exists for large graphs. There exist a lot of variant on the traveling salesman problem. I will consider the form of the problem in which the graph lies in a plane, also known as the Euclidian TSP. This puts constraints on the distances between nodes and is a symmetric formulation of the problem. But still, this is an NP-hard problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To put things into perspective, the number of distinct Hamiltonian cycles through a graph is:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhKsp39tLjVEwuv0HNkhlTvyw34f6vvPzW-ArUfudg4SJeF4iQEMqmzUymOX1YdIP3g1jQwLPpGNY5PPaq_QXur893IvOceWRoPlftP4_c-3ytlAo0a6rmJKK4NhBVjK-cBUe2OCA3WKo8/s1600/Hamiltonian+cycles.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhKsp39tLjVEwuv0HNkhlTvyw34f6vvPzW-ArUfudg4SJeF4iQEMqmzUymOX1YdIP3g1jQwLPpGNY5PPaq_QXur893IvOceWRoPlftP4_c-3ytlAo0a6rmJKK4NhBVjK-cBUe2OCA3WKo8/s1600/Hamiltonian+cycles.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;  &lt;v:stroke joinstyle=&quot;miter&quot;&gt;  &lt;v:formulas&gt;   &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;   &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;   &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;   &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;   &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;  &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;  &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;  &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Enumerating all possibilities becomes infeasible for even small graphs. For &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;n&lt;/i&gt; = 21 the number of solutions is 1,216,451,004,088,320,000. For the case of &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;n &lt;/i&gt;= 101 the number of solutions is approximately 9e+157 which exceeds the approximated number of atoms in the known universe. Of course, I’m not claiming to solve this problem – actually I’m not trying to solve it at all. Many better people have tried that before me. I’ll however focus on testing a TSP solver. It may be exceptionally difficult to solve the problem, but it is possible to construct graphs for which the solution is known (and non-trivial) without too much effort. A model for that could look like:&lt;/span&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigTk2eat2RYumA4IdF67fobjuUD4ftPFEwe3u1kieciVOCiLDjN7oPghnzL0co7l4vcI7AgD9U-gr0jDIsAVOFd-Ap8hNeigb_yhHncWoyzfS0AKoZIpaW2uJX4UJBBx9He3HyQURSKlHf/s1600/TravelingSalesManModel-5x5-center-zoom.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;210&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigTk2eat2RYumA4IdF67fobjuUD4ftPFEwe3u1kieciVOCiLDjN7oPghnzL0co7l4vcI7AgD9U-gr0jDIsAVOFd-Ap8hNeigb_yhHncWoyzfS0AKoZIpaW2uJX4UJBBx9He3HyQURSKlHf/s640/TravelingSalesManModel-5x5-center-zoom.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I plan on doing a series of posts on this problem. In this first post I will define the problem and the method in which I’m constructing a graph for the TSP. In the following posts I will investigate different models for growing TSP graphs, and look into how they perform.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Growing graphs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The intuition behind my approach is to grow the graphs one node at a time. Under certain circumstances the shortest tour can be grown by adding another node causing it to still be optimal in the new graph. Using this approach we start out with a single point that grows to a line, then a triangle. At the triangle stage we have our initial shortest tour. The next step is to &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;splice&lt;/i&gt; in one additional node (&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;v’&lt;/i&gt;) into the graph – this concept is illustrated here:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzsYLZLhqUlGwxyvLIIyJv8TP0rfr4GcikA69Q6sE_-vDgFgYt_HMDb8ii-r1hMjWwh9lMNcjkcYXvmmqToIT8qwamhpVlqv0Uu3CkhJD-EWMBrRso7TKEGlAI_R_SvWdntKIQtD3ypf0K/s1600/Splicing.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzsYLZLhqUlGwxyvLIIyJv8TP0rfr4GcikA69Q6sE_-vDgFgYt_HMDb8ii-r1hMjWwh9lMNcjkcYXvmmqToIT8qwamhpVlqv0Uu3CkhJD-EWMBrRso7TKEGlAI_R_SvWdntKIQtD3ypf0K/s1600/Splicing.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 12pt 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A splice &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;s&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i&lt;/span&gt;&lt;/sub&gt;&lt;/i&gt; is defined as replacing the edge &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;e&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i&lt;/span&gt;&lt;/sub&gt;&lt;/i&gt; with the two edges that form by connecting the endpoints of &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;e&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i&lt;/span&gt;&lt;/sub&gt;&lt;/i&gt; with &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;v’&lt;/i&gt;. The cost of a splicing is defined as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5E3r97DOdXnsCWyhblBWHl1aA-P4uwljte7w7z2bGaY-KClWamxrs6wubkDcVtccpeaq-0RpKHw1s9Zq8KnLxyG-G0cnsdpW3bKqRwdNSgNxzO6mfgXjYmo9lNX0Uws2WDWz9MKIcZGCK/s1600/eq1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5E3r97DOdXnsCWyhblBWHl1aA-P4uwljte7w7z2bGaY-KClWamxrs6wubkDcVtccpeaq-0RpKHw1s9Zq8KnLxyG-G0cnsdpW3bKqRwdNSgNxzO6mfgXjYmo9lNX0Uws2WDWz9MKIcZGCK/s1600/eq1.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 12pt 0cm 10pt; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-theme-font: minor-fareast;&quot;&gt;Where |&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;x&lt;/i&gt;| is the Euclidian length of &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;x&lt;/i&gt;. The cost is simply the extra length added to the path.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The algorithm for growing the graph by one vertex goes as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Given a graph G = (V,E) where E is an shortest tour in G. Consider any node v = (x,y) not in V, define the minimum cost splice over all feasible edges E* constructed from vertex pairs in G (note E is a subset of E*):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXI-99ckJh4_vVwNxlqoqqoCf2rZa6nnTq-s5cX8Ul7Knm-qPDWOywYg04IAFhSjmfN38NcXJGBCQQkca2_pkIIEkXhfDYbMWjtChgxLlkNsWBv6E83Z0Hr5VDRf2C_FhJD-Dxq-jWXn4_/s1600/eq2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXI-99ckJh4_vVwNxlqoqqoCf2rZa6nnTq-s5cX8Ul7Knm-qPDWOywYg04IAFhSjmfN38NcXJGBCQQkca2_pkIIEkXhfDYbMWjtChgxLlkNsWBv6E83Z0Hr5VDRf2C_FhJD-Dxq-jWXn4_/s1600/eq2.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Add v to the graph G if and only if the edge argument minimizer of &lt;/span&gt;&lt;/i&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; is contained in E and:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCoTwWi4w0aHGJOsn8nWdlWLUmoBKNQuFkjYIIJbUowkyOLMgxQkwAuZY91t5y_W1xFaXC-eT4Xsptk-Uu2GFLiWSokfODFGsadjYWgxmLOzXCNGxjsSyillY0-8OPacp66OhudrHdj1VZ/s1600/eq3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCoTwWi4w0aHGJOsn8nWdlWLUmoBKNQuFkjYIIJbUowkyOLMgxQkwAuZY91t5y_W1xFaXC-eT4Xsptk-Uu2GFLiWSokfODFGsadjYWgxmLOzXCNGxjsSyillY0-8OPacp66OhudrHdj1VZ/s1600/eq3.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-theme-font: minor-fareast;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The resulting graph G’ = (V’,E’) is constructed by adding v to V and splicing e&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i&lt;/span&gt;&lt;/sub&gt; in E.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-theme-font: minor-fareast;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Claim: The resulting edge set &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;E’&lt;/i&gt; in &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;G’&lt;/i&gt; is a shortest tour. I will post a mathematical proof of this later in the series.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;As the constructed output graph &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;G’&lt;/i&gt; satisfies the conditions for &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;G&lt;/i&gt; it follows by induction that we can repeat the growth process.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Time for some modeling!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Modeling the Traveling Salesman in Spec Explorer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The first very crude model[1] I’m going to demonstrate will build a graph on a fixed-size integer lattice, where nodes can be added only at the grid points. This implementation may seem very limited, but in fact there is not much difference in modeling an integer lattice versus a floating-point domain, because any integer lattice graph can be scaled to match any graph on a floating-point domain (in-fact a floating-point domain is just a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;really&lt;/i&gt; large integer interval). However, when we constrain the size of the lattice we are of course limiting the flexibility of the model, but the integer representation has some advantages.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Because we are working on a fixed size lattice we can convert any (x,y) point to an integer index. This index is useful when storing the representation of the current graph, because vertices can be held in a &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;SetContainer&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; allowing the model to be independent of the order in which the vertices are added. The same applies to for edges in the shortest tour of the graph.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The model contains just two rules:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TravelingSalesman.InsertVertex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; TravelingSalesman.Solve();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The InsertVertex attempts to grow the current graph by insert a vertex at (x,y) and then checking whether this vertex satisfies the criteria of our growth algorithm.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We start out by exploring a tiny grid (2x2):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Grid2x2: Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TravelingSalesman.InsertVertex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..1}, y &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..1};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; TSM2x2() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;construct&lt;/span&gt; model program &lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; Grid2x2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; scope = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;TravelingSalesManModel.TSMModelProgram&quot;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; TSM2x2NoSolve() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;InsertVertex* || TSM2x2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Exploring this machine results in:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiPFyLM-F7tLr5UctC8Y1atjIDwePAOSrXyidrOfgMeyXdnAxiuL3Mp8nwg81eS3UY_W8RjX5zvyNDq9GyPAUrh1f2-5Arj7qYPIyysLr5wI29IL3DZH_jjzeEESjj5V9WppvLJceEQwHn/s1600/TSM2x2NoSolve.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;160&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiPFyLM-F7tLr5UctC8Y1atjIDwePAOSrXyidrOfgMeyXdnAxiuL3Mp8nwg81eS3UY_W8RjX5zvyNDq9GyPAUrh1f2-5Arj7qYPIyysLr5wI29IL3DZH_jjzeEESjj5V9WppvLJceEQwHn/s640/TSM2x2NoSolve.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;That is 16 distinct graphs with corresponding shortest tour values, which can be feed to a TSM solver. Of course these graphs are far from challenging, but it proves that we are able to grow graphs on a limited size domain. Also it serves to highlight the number of redundant graphs indicated by the high number of cross-over steps. Going just to a 3x3 lattice we immediately run into problems… There exist a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;ton&lt;/i&gt; of possible graphs we can grow. The largest grown graph has 8 nodes out of the maximum of 9. But let’s try instead to slice the model and only generate graphs starting from the center point of the lattice. We can easily do this on a 3x3 grid using:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Grid3x3: Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; TravelingSalesman.InsertVertex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..2}, y &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..2};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; TSM3x3() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;construct&lt;/span&gt; model program &lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; Grid3x3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; scope = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;TravelingSalesManModel.TSMModelProgram&quot;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; TSM3x3CenterScenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(InsertVertex(1,1) ; InsertVertex*) || TSM3x3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This machine slices the model by forcing the choice (1,1) for the first vertex. Exploration results in:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNuECc8NHebMkkT9EJifZyQlJ9yfiqVcGikB4ipm7VqZ-_Qd_L9IoINP6q7GouCMpYd9_9H3ulCTYh9T_ZDnBoi3NiX0qwll907lxvtkQiK65ljbu9AJ3_pCWjmhvp_MQVus4vCLiy0RiY/s1600/TSM3x3Center.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;32&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNuECc8NHebMkkT9EJifZyQlJ9yfiqVcGikB4ipm7VqZ-_Qd_L9IoINP6q7GouCMpYd9_9H3ulCTYh9T_ZDnBoi3NiX0qwll907lxvtkQiK65ljbu9AJ3_pCWjmhvp_MQVus4vCLiy0RiY/s640/TSM3x3Center.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is an extremely complicated solution. The problem here is of course that solution space (the number of applicable graphs) is itself extremely large, and because we are doing Model-Based Testing we are actively seeking to construct any feasible solution from this space.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;It is fairly easy to construct a large set of test cases (this model constructs 240 test cases) from this problem space. They all pass against my crude implementation of a TSM solver. The problem however, is that they are not really taxing the implementation because they are all very small graphs, inside a tightly constrained grid. We can of course easily increase the size of the grid, however, the number of small graphs explodes even more.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We have seen how a model can be designed to grow graphs for the Traveling Salesman. However, the crude model struggles already on tiny input domains and produce a large number of uninteresting test cases. In the coming posts I will, formally prove that the algorithm for growing the graphs works. Furthermore, I plan on investigating how we can further slice the crude model to generate graphs of higher complexity.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[1] &lt;/span&gt;&lt;a href=&quot;http://api2.ge.tt/0/8xsa6cD/0/blob/download&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Traveling Salesman Model&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/6590194317907909122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/02/modeling-traveling-salesman.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/6590194317907909122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/6590194317907909122'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/02/modeling-traveling-salesman.html' title='Modeling the Traveling Salesman'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhKsp39tLjVEwuv0HNkhlTvyw34f6vvPzW-ArUfudg4SJeF4iQEMqmzUymOX1YdIP3g1jQwLPpGNY5PPaq_QXur893IvOceWRoPlftP4_c-3ytlAo0a6rmJKK4NhBVjK-cBUe2OCA3WKo8/s72-c/Hamiltonian+cycles.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-2904047267694409762</id><published>2012-02-03T12:32:00.000-08:00</published><updated>2012-02-03T12:32:33.973-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="binary seach tree"/><category scheme="http://www.blogger.com/atom/ns#" term="BST"/><category scheme="http://www.blogger.com/atom/ns#" term="code coverage"/><category scheme="http://www.blogger.com/atom/ns#" term="finite"/><category scheme="http://www.blogger.com/atom/ns#" term="infinite"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="slicing"/><title type='text'>Model Slicing with Spec Explorer</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;It’s been some time since I had the chance to blog on MBT. January 2&lt;sup&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;nd&lt;/span&gt;&lt;/sup&gt; 2012 my second son was born, and I’ve been on three weeks of paternity leave. Since then I’ve been too busy at work to squeeze in time to play with MBT, but now I’ve finally managed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;  &lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Today I want to talk about model slicing which is one of the more advanced features of Spec Explorer. Slicing is extremely powerful, because it allows you to build your models very generically, and then create many slices of that model with differing purposes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I’m going to show some very simple examples on how slicing works, and then I will dig up the &lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2011/05/application-of-model-based-testing-to_27.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Binary Search Tree model&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; to illustrate how this would work in practice.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Slicing&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;For my example on slicing I’m going to construct a very simple model. The state is one integer variable, and I have two rules defined the following way:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;A()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; A()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value *= -1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;B()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; B()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Rule “A” flips the sign of the value and “B” increases it by one. The state space of this model is infinite. If you explore it you get something like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtuPg3FlB-yyxHzxtRLeSuHY5AwVFBBesYByoQq9Ulux0oMJfs40B5TSo5jaw-qxtjkzroadoc2-RH5P5A4sgd05_1NYp88AqX-8Vj7nR7p29_HkbZW1-t7r2LMo7J-0NbzQ155aJbsuIc/s1600/example_explore.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtuPg3FlB-yyxHzxtRLeSuHY5AwVFBBesYByoQq9Ulux0oMJfs40B5TSo5jaw-qxtjkzroadoc2-RH5P5A4sgd05_1NYp88AqX-8Vj7nR7p29_HkbZW1-t7r2LMo7J-0NbzQ155aJbsuIc/s640/example_explore.JPG&quot; width=&quot;286&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;  &lt;v:stroke joinstyle=&quot;miter&quot;&gt;  &lt;v:formulas&gt;   &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;   &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;   &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;   &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;   &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;  &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;  &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;  &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/span&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Let’s look at what we can do using slicing. In general slicing works like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Scenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(A | B)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; SlicedAccumulatorModelProgram() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Scenario || AccumulatorModelProgram&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;You define a “scenario” and then you interleave it with your model program. The above scenario (A | B) will do either A or B, but only one of them:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjetFtWe75k63on1f_rwUkMu_6lxEFnHSHD0eRHxwXu_eEAJWAN72IInr9RW7pnIS5iEkgADiJ7_pVy4c0opGSxmwrDhzAoTWFc-X2LsznXt8eByfr7YFxsTu95FYLLcqiAzFh0sJX0ef5O/s1600/example_a_or_b.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjetFtWe75k63on1f_rwUkMu_6lxEFnHSHD0eRHxwXu_eEAJWAN72IInr9RW7pnIS5iEkgADiJ7_pVy4c0opGSxmwrDhzAoTWFc-X2LsznXt8eByfr7YFxsTu95FYLLcqiAzFh0sJX0ef5O/s1600/example_a_or_b.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We can also use slicing to fix a sequence of rules. Say we would like to first execute A then followed by B, we can do that using:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Scenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(A ; B)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM9iC3PzRwf-UZoRTOb5Q5-M5a3b3bo3fakAw6JVRjZwLY6YyctPp6mzPlH8o2n5o_u_Wka5dz8lruF0PTbhDddylMGHcC_7B_GwU_UJYNGSJMwrBriojjTSpCoI162STuUeb0OjWBZf9c/s1600/example_a_b.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM9iC3PzRwf-UZoRTOb5Q5-M5a3b3bo3fakAw6JVRjZwLY6YyctPp6mzPlH8o2n5o_u_Wka5dz8lruF0PTbhDddylMGHcC_7B_GwU_UJYNGSJMwrBriojjTSpCoI162STuUeb0OjWBZf9c/s1600/example_a_b.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We can combine sequences by concatenating them:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Scenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(A | B) ; (A ; B)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinqHN3UE6v9lhlYxjBh3LcKS5OY0JzKpYzrEwqKOscSh-pvtVqltGlHDCJfS15aOAmjoh_TMmC7o7EBepC0dFua6AvyzHH6eXFWaQx-f2IGCFFj0-s6YDKh3H8nUWpOZ7AJ5Nrg0O3ffIm/s1600/example_a_or_b_a_b.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinqHN3UE6v9lhlYxjBh3LcKS5OY0JzKpYzrEwqKOscSh-pvtVqltGlHDCJfS15aOAmjoh_TMmC7o7EBepC0dFua6AvyzHH6eXFWaQx-f2IGCFFj0-s6YDKh3H8nUWpOZ7AJ5Nrg0O3ffIm/s320/example_a_or_b_a_b.JPG&quot; width=&quot;78&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We can repeat a scenario:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Scenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;B*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj35hxYmFihFaRibla2JcAp_S8ypClPMXW5VsI1HStR41HQeXovmPfEhm-LLeIBeJQ38xJMA3e3XVnaEc2pCUOrRxwzBhwhP6TlIWtDutSFLPQg7HPoo8XW-mIliq74WFLsfeH6iFAWbxZX/s1600/example_repeat_b.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj35hxYmFihFaRibla2JcAp_S8ypClPMXW5VsI1HStR41HQeXovmPfEhm-LLeIBeJQ38xJMA3e3XVnaEc2pCUOrRxwzBhwhP6TlIWtDutSFLPQg7HPoo8XW-mIliq74WFLsfeH6iFAWbxZX/s320/example_repeat_b.JPG&quot; width=&quot;45&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Repeating B is itself an infinite model because it simply grows the counter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interestingly we could also repeat A but this just yields:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiumu1wKgsGZy9OOkfEjE17h1ooJPIvIfynuTx_07M_toCZxQTJL2gInf093o9CFgXabxE70PAUbGePaSSnqDr-d1zTfRvG8uQvju2qCIKyrYl29uB-jFnWb8fffD3z27IXLUFKwCNQkqIV/s1600/example_repeat_a.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiumu1wKgsGZy9OOkfEjE17h1ooJPIvIfynuTx_07M_toCZxQTJL2gInf093o9CFgXabxE70PAUbGePaSSnqDr-d1zTfRvG8uQvju2qCIKyrYl29uB-jFnWb8fffD3z27IXLUFKwCNQkqIV/s1600/example_repeat_a.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Because flipping the sign on zero has no effect.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We can do B followed by A repeatedly instead:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Scenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;B ; A*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7O3xRFKz1S17wXuJw4jq2qaEMTGZIew8bVDLjbLVvNLp7IL8q3DxU65MpYfR4OhIPltUtIH4U9W7dLDzT5Vt6vcQJjMUgRCNXJRQUbBcsiY7cMDgyzhiIhIVqknFn2cW7BosmUzBdcUZy/s1600/example_b_repeat_a.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7O3xRFKz1S17wXuJw4jq2qaEMTGZIew8bVDLjbLVvNLp7IL8q3DxU65MpYfR4OhIPltUtIH4U9W7dLDzT5Vt6vcQJjMUgRCNXJRQUbBcsiY7cMDgyzhiIhIVqknFn2cW7BosmUzBdcUZy/s1600/example_b_repeat_a.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now A has an effect, but it repeats over two values (-1 and 1) so the sliced model is finite.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Interestingly we can construct other repeated scenarios that also results in a finite model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Scenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(A; B)*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6yCIM3nUsBw6qBzGGNLS0v-_hOpcbJJfp6MnHUxnjOrZ5ENjBnCibpzamN2c1hNnneqE9rPzsyVgUNJ-yF9sDvFlWv0wjat16gifp2j68HM_avLhR-uxPu0-bS7WP3pST8stpQDh6xDjU/s1600/example_repeat_ab.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6yCIM3nUsBw6qBzGGNLS0v-_hOpcbJJfp6MnHUxnjOrZ5ENjBnCibpzamN2c1hNnneqE9rPzsyVgUNJ-yF9sDvFlWv0wjat16gifp2j68HM_avLhR-uxPu0-bS7WP3pST8stpQDh6xDjU/s1600/example_repeat_ab.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;When repeating A followed by B this causes the combined action to alternate between increasing and decreasing the value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is just some of the very basic things that we can do using slicing. I will stop the example here and continue on to a real example.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Slicing applied to a binary search tree&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Enough with the toy examples, let’s try this on the BST case. If you go back and read up on the BST model you will find that one of the conclusions we drew back then was that for MBT to generate a model that would provide us with 100% code coverage of the BST implementation we were forced to model trees of size 4, quoting:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoQuote&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;em&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;“For this special case the node being deleted must have both a left and right sibling and in addition the right sibling must also have a left sibling […] it is simply not possible for the model to construct such a tree because it is limited to using 3 nodes. To cover this scenario, we would need to extend the model parameter ranges to Add and Remove from 0..2 to 0..3. […] Were you to generate the tests, you would end up with 193 test cases.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The statement is still true; we need four nodes in the tree. But a generic 4-node model has shown to be overkill. Instead what we can do is fix the values of the two first nodes and then continue with the generic model from thereon. I will show you how we obtain this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;First we split the input range into two ranges, one which we use in our slicing (fixing parameters) and one that we let Spec Explorer choose parameters from:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; ParameterCombination: Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; BSTTest.Add(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..1};&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; BSTTest.Remove(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {-1,0..1};&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; SlicedParameter: Main &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;action&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; BSTTest.Add(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {-2..-1};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The slice will use x values -2 and -1, while the generic model will use 0 and 1. For the slice we do not intend to model the Remove method. You can very well also model Remove, it’s just not necessary. Keep in mind though if you were to model Remove generically on the inputs -2 to 1 then the model can Remove nodes -2 and -1 but it cannot re-add them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Next we need to construct a model program for the sliced input parameter (-2 and -1). This is an exact copy of the generic model program just using a different input configuration:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; SlicedModelProgram() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;construct&lt;/span&gt; model program &lt;span style=&quot;color: blue;&quot;&gt;from&lt;/span&gt; SlicedParameter &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; scope = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Combinatorics.BSTModelProgram&quot;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;You can explore this model, but because we didn’t limit the input parameters to Remove, it will just explode (where you to implement the Remove method in the sliced configuration it would just be an exact duplicate of the model on 1 and 2).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The next step is to define the actual scenario we are interested in. To obtain the required base tree we need to add nodes -1 and -2 – in that order:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; SlicedTreeScenario() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Add(-1); Add(-2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Too simple, right? You can explore this scenario:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTPlth65j1T04Fl2s-YzjYkZgHzLC_tAjRlx1aO-dKB5vM00-lREJ5fddiBj6um2Z3pMMrnmRS2EFeY9JfjcLQ1nFwd_-nqWr1yhGmvMumywJBsgcdYhZV-Z0GbLpZQ2QJ1SPH95MIwzsh/s1600/slicing+scenario.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTPlth65j1T04Fl2s-YzjYkZgHzLC_tAjRlx1aO-dKB5vM00-lREJ5fddiBj6um2Z3pMMrnmRS2EFeY9JfjcLQ1nFwd_-nqWr1yhGmvMumywJBsgcdYhZV-Z0GbLpZQ2QJ1SPH95MIwzsh/s1600/slicing+scenario.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice that this is just a static scenario – nothing is explored yet, thus some values are unknown.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Once we interleave this scenario with a model program, Spec Explorer will look for the sequence S0: Add(-1)/_ Add(-2)/_ in the model program and only include those branches that contains this sequence. The underscores are wildcards, that can take any value. In this case Spec Explorer will accept Add(-1)/True or Add(-1)/False. If you omit a parameter (or return value) it is treated as an underscore. You can also specify directly the required output to be True in our case, but it does not matter because the sequence Add(-1); Add(-2) will always return True for both rules. Where you instead to construct the scenario: Add; Add/False, then you tell Spec Explorer that the second Add call must return False which only happens in the cases where the same value was added twice (e.g. Add(-1)/True; Add(-1)/False). Hopefully this makes sense.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now we interleave this scenario with our slicing model program to generate the sliced model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; SlicedTreeModelProgram() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SlicedTreeScenario || SlicedModelProgram&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;And we can also explore this model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ7Ih7fPI5OtHqpBTd6tLUGjJr0Jwj-ibTU-3vlyECgA1AHBHqaarSs8Jyu8Pq54Xw807BBywnrS8N625jSk7dKQI2PQpQxDbyyofm0JkliMJki2PkBHLfvksnIgOnpHtttQQdaNVMAQcZ/s1600/sliced+model.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ7Ih7fPI5OtHqpBTd6tLUGjJr0Jwj-ibTU-3vlyECgA1AHBHqaarSs8Jyu8Pq54Xw807BBywnrS8N625jSk7dKQI2PQpQxDbyyofm0JkliMJki2PkBHLfvksnIgOnpHtttQQdaNVMAQcZ/s1600/sliced+model.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now that we have interleaved the actual model we get actual model exploration, which we can see by the fact that the states contain data. Now the exploration was fixed because we told it just to follow one scenario, but we are free to do more with this sliced model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; JoinedBSTModelProgram() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SlicedTreeModelProgram ; BSTModelProgram&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This joined model program starts out by exploring our sliced model program and then carries on exploring the generic model:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihaIbki7iRxnZRwvdzoLsnGMN-jnHQ0T1mBAFco_3CExiMJJyXWh7UPEtDMlLb-zvMNgNIC3xWxEUyi-Rklv5-UHYjYzDXWB7ZTeY3HIH1rPdoG8DxkKnyf-flJwwaUvzSu9suU80rZSqo/s1600/joined+model.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;634&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihaIbki7iRxnZRwvdzoLsnGMN-jnHQ0T1mBAFco_3CExiMJJyXWh7UPEtDMlLb-zvMNgNIC3xWxEUyi-Rklv5-UHYjYzDXWB7ZTeY3HIH1rPdoG8DxkKnyf-flJwwaUvzSu9suU80rZSqo/s640/joined+model.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;From the exploration graph it is evident that all states start out with the -1,-2 sequence, which is exactly what we wanted. The tree structure we wanted to build from the original description conforms with the tree built in state (-1,-2,1,0).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Because we fixed the input sequence to start with Add(-1); Add(-2) we obtain 4-node trees with the right construct with only 12 states, and generating tests from this model results in just 16 additional test cases instead of the 160 tests we got in addition when going to a 4-noded generic model.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Generating and executing the tests from the two models results in 100% code coverage of the BST class:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihePWW5zOh815r2j2kRgD2kfk_0T0DRWxZbp4YqVkttKEM4Nqo3ECZunZJbeGJe28OyS4j9sMnnugQloeGmKFM8TzUDCa9pXuUIeMypX7i3_3H-3t_6vTT2cis1OlzvLwp_FZbvRCS75VT/s1600/code+coverage.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;148&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihePWW5zOh815r2j2kRgD2kfk_0T0DRWxZbp4YqVkttKEM4Nqo3ECZunZJbeGJe28OyS4j9sMnnugQloeGmKFM8TzUDCa9pXuUIeMypX7i3_3H-3t_6vTT2cis1OlzvLwp_FZbvRCS75VT/s640/code+coverage.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Model slicing is a powerful feature of Spec Explorer which allows you to generate additional models that are sliced subsets of a bigger model. This is very useful in cases where we are interested in the behavior of the system under some special circumstances – like the binary search tree example.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Using model slicing you can also model your system without any limitation, creating infinite state space models. Then this infinite model can be sliced into many finite models later. This allows you to think more about the system you are modeling and less about how to avoid the state space blowing up. Furthermore, you can use slicing as a means to look into your infinite model and see if it behaves correctly in a constraints environment. This can help you spot inconsistencies in your infinite models. Once you are happy with your infinite model you can let Spec Explorer go nuts on it using On-The-Fly testing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;You can also dictate exact scenarios if you are interested in some specific scenario. So in our BST case we could just have written:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; Test() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; ForExploration = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;((Add(-1) ; Add(-2) ; Add(1) ; Add(0) ; Remove(-1)) || UnparameterizedBSTModelProgram)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To construct the exact scenario we were looking for. Although this has little to do with modeling, and we could just as well write a unit test to do that. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/2904047267694409762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2012/02/model-slicing-with-spec-explorer.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/2904047267694409762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/2904047267694409762'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2012/02/model-slicing-with-spec-explorer.html' title='Model Slicing with Spec Explorer'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtuPg3FlB-yyxHzxtRLeSuHY5AwVFBBesYByoQq9Ulux0oMJfs40B5TSo5jaw-qxtjkzroadoc2-RH5P5A4sgd05_1NYp88AqX-8Vj7nR7p29_HkbZW1-t7r2LMo7J-0NbzQ155aJbsuIc/s72-c/example_explore.JPG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-2632434114595366939</id><published>2011-12-19T23:37:00.000-08:00</published><updated>2011-12-19T23:59:04.057-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="heuristic oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="pragmatic"/><category scheme="http://www.blogger.com/atom/ns#" term="school"/><category scheme="http://www.blogger.com/atom/ns#" term="test oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="theoretical"/><category scheme="http://www.blogger.com/atom/ns#" term="validation"/><title type='text'>Are Test Oracles a mathematical nicety to cover-up problems?</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;Last week I had an interesting discussion with a colleague that did not agree with my take on Model-Based Testing. He was unwilling to buy my arguments for why Model-Based Testing is a more efficient way of automating test cases compared to traditional scenario automation. He was a firm believer in Model-Based Testing but his experiences told him that modeling was an expensive cost up-front, which could be made up for in maintenance savings, whereas I claimed that modeling was a much cheaper automation approach.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Furthermore, he argued that my model was close to useless, because it did not come with a validation oracle. At a deeper level, the discussion also revealed some interesting discrepancies to me: He believed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Needless to say, we never reached agreement on the subject – but I realized later on that we were arguing from completely different perspectives.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;After the discussion I started thinking: “How can we be of so differing opinions?” After fumbling around with this question in my head over the weekend, I realized that we were using Model-Based Testing for two completely separate purposes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A notion started to form in my head – it seemed that there were different ‘schools’ (or views) within Model-Based Testing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Theoretical modelers&lt;/b&gt;: They want strict rules around their models, and conduct rigorous validation in an effort to validate the conformity of their models. They have a theoretical approach to software testing and like to mathematically prove algorithms and construct test cases that cover &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;just&lt;/i&gt; the necessary and sufficient cases.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 10pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;·&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Pragmatic modelers&lt;/b&gt;: They are more of the ad-hoc modeling type. They have a pragmatic approach to Model-Based Testing in which a model is valuable on its own. They understand that the model &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;should&lt;/i&gt; be validated, but they can live with limited validations. They see value in the model as a means for communication.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Of course, there is no &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;right&lt;/i&gt; way of modeling. Both schools in the extreme limits are losing the grip on reality. If you dig yourself too deeply into the theoretical aspects of modeling you will stagnate, whereas a too pragmatic approach to modeling most likely results in low quality models.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;However, I find myself to be closer related with the latter group. I tend to want to see my models grow before I care too much about validation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;My take on Test Oracles&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This prelude story brings me to the actual point I want to discuss today: Test Oracles.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In software testing a Test Oracle is an entity in the system which – just like in the movie “The Matrix” – holds all the answers, at any point you can ask your test oracle “is the system in a valid state?” and it will tell you the answer. Very handy for Model-Based Testing!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Test Oracles are also these imaginary things that testers like to talk about, but no one have actually seen nor written. Okay, maybe I’m being a bit harsh here, but except for very isolated cases, Test Oracles are intractable because the complexity of the underlying system is too high. I have the feeling that in many cases problems are deferred by relying on some Test Oracles to be written in the “near future”, in an effort to ignore the tough problem of writing solid validation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I believe the two Model-Based Testing schools are fundamentally different in their view on validation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Theoretical modelers will seek to write strict Test Oracles at first, which is a &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;really&lt;/i&gt; challenging task. I believe this is one of the reasons why Model-Based Testing is perceived as being difficult. If you start thinking too much about oracles and validations, you never get started on your modeling.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Pragmatic modelers on the other hand are much more likely to explore Model-Based Testing without dealing with the validation problems initially, and rely on Heuristic Oracles later on. This makes for a lower barrier to entry.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Heuristic Oracles are approximation oracle; they will tell you if something has gone totally awry. For example a heuristic invariant could be that a computed length value must never be negative.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In conclusion Test Oracles are nice for closed problems, where it is easy to identify invariants that are necessary and sufficient to prove an algorithm – like sorting algorithms or tree-structures. But, aside from the text-book examples on algorithms and data structures, frankly most test problems are infeasible to write Test Oracles for. For any large-scale system, writing an Oracle would be too time-consuming, and most likely it would end up being more complicated to maintain than the actual product you are trying to test. Heuristic Oracles are less strict in their validation, but they allow testers to get some value out of their initial modeling efforts, and lower the entry barrier.&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;[1] &lt;a href=&quot;http://www.softwarequalitymethods.com/Papers/STQE%20Heuristic.pdf&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Heuristic Test Oracles&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/2632434114595366939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/12/are-test-oracles-mathematical-nicety-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/2632434114595366939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/2632434114595366939'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/12/are-test-oracles-mathematical-nicety-to.html' title='Are Test Oracles a mathematical nicety to cover-up problems?'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-6669335733326845020</id><published>2011-12-06T00:11:00.000-08:00</published><updated>2011-12-06T00:11:23.681-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coverage"/><category scheme="http://www.blogger.com/atom/ns#" term="implicit"/><category scheme="http://www.blogger.com/atom/ns#" term="iterative"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="requirements"/><category scheme="http://www.blogger.com/atom/ns#" term="tools"/><category scheme="http://www.blogger.com/atom/ns#" term="vendor"/><title type='text'>Requirements and Model-Based Testing: A rocky road</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This post is on something that has been bogging my mind a lot lately, which I haven’t been able to fully express, but I’m hoping getting it published will help me settle my mind.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I had the pleasure of attending the ETSI Model-Based Testing User Conference – and let me start by giving kudos to all the great people in the field attending and giving some sharp presentations!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;At the conference I got a look into all the available vendor tools for Model-Based Testing (I won’t list them here; this is not supposed to be an advertisement blog). All of them are pretty powerful tools, and they allow you to build models from a set of requirements that you gather in the beginning. In the model you specify which actions corresponds to a certain requirement – e.g. in finance you may have a requirement that &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;posting a sales order will produce a set of ledger entries&lt;/i&gt; so this requirement would be associated with the posting action. Some can even import your requirements from external tools, and keep track of changes to requirements. This is all pretty nice, and one tool showed the ability to visualize the impact of a requirement change directly in the rendered model view – now that is awesome!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A significant number of presenters at the conference were also happy to report that they had discarded existing metrics for quality of their software testing, and replaced it with requirements coverage. Meaning, they now record the number of times requirements are covered in their generated test suite.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;But then a thought came to me:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;“If I know all my requirements up-front, why would I use Model-Based Testing instead of just writing one or two scenario tests per requirement, which I know covers these requirements well?”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Well, the reason I would use Model-Based Testing is that it produces many more permutations of actions sequences that I would not care to test if I had to write the scenarios by hand. I usually start out writing a very crude and simple model, which has some limited value (it covers few and basic requirements) and then I see what happens when I run the tests. Almost always I find that some of my tests break because some preconditions were not met. This means that the executed action was not valid from the given state, and I have a model error. I then analyze these failures and turn them into preconditions on the actions, such that they are no longer executed from states where they are invalid in the SUT.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So what actually just happened here? By developing the model iteratively we start to reveal more information about the SUT, but every time we have to put in a precondition check on an action, we have actually uncovered an unknown requirement. For example we didn’t actually know that “&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;you are not allowed to delete an item from a list if the list is empty&lt;/i&gt;” (sounds a lot like a requirement to me…) before we tried it! Once we tried doing it we uncovered an unknown or implicit requirement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This sparked another thought:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;“When was the last time I developed a feature where I knew all the requirements up-front?”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;And the truth is, it never really happened, because most features I have worked on were either too complicated to document requirements fully, or the feature evolved over time because new ideas emerged.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In this new world of Scrum &amp;amp; Agile, modeling from your requirements feels very much like the old way of doing things – almost like the waterfall approach to software testing. In my view on Agile, the team cannot expect to fully understand the requirements when they set out to work on their feature.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Don’t get me wrong, I think it’s important to keep track of your requirements, and verify that they indeed are covered by your model and generated test suite. It serves as a sanity check, because modeling is a difficult challenge, and you can easily leave out a requirement in your model or generate a test suite that misses one or more requirements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;But please leave it at this, don’t get too focused on your known requirements, they are not what matters most. The real beauty of Model-Based Testing is its ability to uncover implicit requirements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/6669335733326845020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/12/requirements-and-model-based-testing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/6669335733326845020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/6669335733326845020'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/12/requirements-and-model-based-testing.html' title='Requirements and Model-Based Testing: A rocky road'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-7848354262730284868</id><published>2011-11-13T08:04:00.000-08:00</published><updated>2011-11-13T08:04:28.431-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="automation"/><category scheme="http://www.blogger.com/atom/ns#" term="baseline"/><category scheme="http://www.blogger.com/atom/ns#" term="risk analysis"/><category scheme="http://www.blogger.com/atom/ns#" term="risk profile"/><category scheme="http://www.blogger.com/atom/ns#" term="strategy"/><category scheme="http://www.blogger.com/atom/ns#" term="targeted effort"/><category scheme="http://www.blogger.com/atom/ns#" term="weighing"/><title type='text'>Model-Based Testing of Legacy Code – Part II – Risk Profiling</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;Last time I left you after describing my latest challenge – making sense of a large piece of legacy code. I eluded to the fact that we started building a risk profile for the changelist that made up the difference between a well-tested root branch and a poorly tested branch.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Okay, so what did we do to tackle this immense problem? Well, our approach was to compute a risk profile based on a model of the probability of code lines containing bugs. Without digging too deep into the mathematics, this is how the profile is built:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;All lines of code for files that differs are loaded into the profile&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;B)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Each line of code is assigned two risk weights: Test coverage, and difference weights&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 10pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;C)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;For each file the weights are summed up and normalized and a third weight is introduced: Revision weight&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The three weights are combined into a total weight for each code line and aggregated up to file level. The computation is a weighted average of the normalized weights, where the test coverage and difference weights are multiplied together:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioZ5u4tQOEvHexrkti4x5SrFAT-8hCnGfRrb2TSPwCWYVpC9EfEf85kto6OrXnGr3bs4sHwhVIWeq8X_6bI_B50CIw3vf331r14NhcFufPLRdTFhVjIUMnm1J6fttO-YjL0FWdD3Ga_puu/s1600/risk_equation.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;68&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioZ5u4tQOEvHexrkti4x5SrFAT-8hCnGfRrb2TSPwCWYVpC9EfEf85kto6OrXnGr3bs4sHwhVIWeq8X_6bI_B50CIw3vf331r14NhcFufPLRdTFhVjIUMnm1J6fttO-YjL0FWdD3Ga_puu/s320/risk_equation.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt 36pt; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;  &lt;v:stroke joinstyle=&quot;miter&quot;&gt;  &lt;v:formulas&gt;   &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;   &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;   &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;   &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;   &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;   &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;   &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;   &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Test coverage weight – &lt;/b&gt;this weight is used for reducing risk for lines of code that have good test coverage. The weight of a code line is reduced by 10% for every test case that covers this particular line of code. The more tests that hit the line of code the more the weight is reduced. The assumption is that tests are conditionally independent and that a given test case has 10% probability of detecting a bug on this code line. Furthermore, this 10% reduction is improved if the test case touches fewer code lines – the rationale is that the lower level the test is written at, the higher likelihood of validating the correct code line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Difference weight –&lt;/b&gt; this weight is used for weighing the lines of code that were changed from our root branch higher than the ones that were not changed. In our programming language we distinguish between actual code lines and “empty” lines, which are lines that contain meta-data definitions and statements that are not actually executed at runtime (e.g. switch, try, catch, etc.). Empty lines cannot be covered by tests, and as such it makes no sense to include them in the risk profile – however, they can still be different from the root branch. The difference weight is set to 1.0 if the code line was changed and 0.0 if it was not changed. Empty lines that were changed are summed up and distributed evenly on all code lines – the rationale being that we cannot identify which code line carries the risk, so we split it over all code lines not to ignore the fact that a line was actually modified.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Revision weight –&lt;/b&gt; this weight kicks-in at the file level (on code lines it is zero), and it is extracted from the source control system and counts the number of changes that were made to the file from the time the branching was made. This effectively measures the “churn” on the files and weighs them by how often they are churned.&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;margin: 10pt 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Cambria;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/h3&gt;&lt;h3 style=&quot;margin: 10pt 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Cambria;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Sample risk profile&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To illustrate what this profile looks like I’ve generated a sample profile for some of our code. The code has been obscured by removing file name references, but each column on the y-axis represents an individual source file, and the x-axis shows the associated percentage risk associated with a given file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmBZq99GE5vS1dQ8kN_QCa8YaceLFyMzdGGOwXgGnzDAWnLZO8eB19NmDq3okyZGT85QE_ewT7zTx9_TmC6pCTVNDwdPgOFE97p8LKPSU3ZYifBH9_zekI8vEmamLUM7bDxFbAjgbJg4w7/s1600/risk_profile.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;390&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmBZq99GE5vS1dQ8kN_QCa8YaceLFyMzdGGOwXgGnzDAWnLZO8eB19NmDq3okyZGT85QE_ewT7zTx9_TmC6pCTVNDwdPgOFE97p8LKPSU3ZYifBH9_zekI8vEmamLUM7bDxFbAjgbJg4w7/s640/risk_profile.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;From this profile it is easy to spot outliers (or high risk files) that can be selectively targeted for test coverage. Also the profile gives you a strategy for reducing the risk at the fastest rate, by starting with the files with the highest risk and working downwards through the list. Furthermore, we can drill down on a single high risk file to look at the file level pattern.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This gives us a starting point for our analysis. If we were to ship the product right now we would incur 100% risk; however the risk profile allows us to give a reasonable estimate of the effort involved in reducing the risk. We can for example write tests for a single high risk file and thus estimate the effort required to reduce the risk by 3-4% (in our case). We can extrapolate this information and give an estimate on the effort required if we want to incur only 50% risk when shipping. Or if we are date-driven we know the amount of resources available, and can estimate the level of risk we will be shipping with.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;By re-running the risk profile after additional tests have been produced and comparing the total absolute risk of the new profile with the baseline profile an accurate risk reduction factor can be computed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;However! It’s crucial to understand that a risk profile is &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;relative&lt;/i&gt; to a certain baseline. That is, it tells you where to target your efforts to bring down the risk at the fastest rate from where you are now, but it does not tell you anything about the current state of the product – this understanding needs to come from you! A risk profile will &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;always&lt;/i&gt; sum up to 100% risk. A product could be in excellent state and ready to ship, and if you run a risk profile on it at that point in time you will ship with 100% risk. Don’t make the mistake of comparing risk profiles for different branches either, as you will be mixing apples and oranges. A risk profile is relative, and if your baselines do not match up, neither will your risk profiles be comparable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This was a pretty in-depth explanation of how we build risk profiles. I hope it is inspiring for others to read about our approach! Next time we will look into how we can use these risk profiles in our choice of automation strategy, and finally we will get to the Model-Based Testing part of it!&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/7848354262730284868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/11/model-based-testing-of-legacy-code-part_13.html#comment-form' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/7848354262730284868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/7848354262730284868'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/11/model-based-testing-of-legacy-code-part_13.html' title='Model-Based Testing of Legacy Code – Part II – Risk Profiling'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioZ5u4tQOEvHexrkti4x5SrFAT-8hCnGfRrb2TSPwCWYVpC9EfEf85kto6OrXnGr3bs4sHwhVIWeq8X_6bI_B50CIw3vf331r14NhcFufPLRdTFhVjIUMnm1J6fttO-YjL0FWdD3Ga_puu/s72-c/risk_equation.PNG" height="72" width="72"/><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-8686584362567013792</id><published>2011-11-02T03:54:00.000-07:00</published><updated>2011-11-02T03:54:11.553-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="feature"/><category scheme="http://www.blogger.com/atom/ns#" term="integration point"/><category scheme="http://www.blogger.com/atom/ns#" term="legacy"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="risk analysis"/><title type='text'>Model-Based Testing of Legacy Code – Part I</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;It has been&amp;nbsp;a while since I had time to post on this blog. I&#39;ve been kept busy attending the Model-Based Testing User Conference - it had some really great presentation, that I also want to find some time on reporting on. I have a trip report ready, but I need to boil it down to the relevant stuff before I post it here. Granted, my next post is not going to be on Model-Based Testing, but it will however be the first in a series of posts that - with a bit of luck - will build up to some really interesting Model-Based Testing!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;That being said, let&#39;s jump into it. Recently&amp;nbsp;I’m being faced with a challenge of taking a large set of legacy code changes and test it in a way that is sensible. I work with a colleague in a two man team on solving this problem.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;You can think of the changes as a source control branch. The root branch has good test coverage, but the new branch has no automated test coverage. The changes contains both added functionality to the product, but also smaller tweaks to existing code in the form of changes to existing functionality and regulatory changes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The objective is of course to apply Model-Based Testing somehow, but the major challenges are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;How do we make sense of this new branch?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;B)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;How do we approach automation of legacy functionality?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;C)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;How much can be obtained from modeling?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I will be writing a few blog posts for the coming weeks on the progress we make as we go along, but ultimately I would like to hear from my readers, what ideas they have on how to tackle this problem.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So let’s start with the first challenge...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;strong&gt;How do we make sense of this new branch?&lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We decided to analyze the changes and group them into two sets: Features and integration points. A feature is a coherent set of changes that was developed in the same go, whereas integration points cover the incoherent changes that are either smaller or made over a longer period of time. Later we will see how this categorization affects the automation strategy we would like to apply.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Luckily we have documentation that names these features and link them to source files, so we do not have to make a detailed analysis to uncover what is coherent and what is not. Some documented features are small and can be seen more as integration points.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;All integration points can be identified through a simple source code difference analysis. Notice this includes all features as well. It’s an open challenge how to identify overlap...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This was a brief introduction to the upcoming project from my side.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The next step that we are working on is coming up with a structured approach on how to handle legacy code, where we build a risk profile over the changes, more on this next week...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/8686584362567013792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/11/model-based-testing-of-legacy-code-part.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/8686584362567013792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/8686584362567013792'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/11/model-based-testing-of-legacy-code-part.html' title='Model-Based Testing of Legacy Code – Part I'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-5914702044168228097</id><published>2011-10-18T10:02:00.000-07:00</published><updated>2011-10-18T10:02:27.794-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="boundary value"/><category scheme="http://www.blogger.com/atom/ns#" term="container"/><category scheme="http://www.blogger.com/atom/ns#" term="domain"/><category scheme="http://www.blogger.com/atom/ns#" term="domain input partitioning"/><category scheme="http://www.blogger.com/atom/ns#" term="equivalence"/><category scheme="http://www.blogger.com/atom/ns#" term="interface"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="sampling"/><title type='text'>Dealing with floating points in models - Part II</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Today I’m going to follow up on &lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2011/10/domain-input-partitioning-dealing-with.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Part I&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, but I’ll give you the implementation details of the classes. I provided you with a generic interface:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now as I pointed out previously, we can choose to implement this interface for any domain type, so let’s try implementing it for a &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; domain:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainDoubleSampler&lt;/span&gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; Maximum { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 100.0; } }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; Minimum { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; -100.0; } }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; BoundaryNegative(&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; boundary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; boundary - &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;.Epsilon;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; BoundaryPositive(&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; boundary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; boundary + &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;.Epsilon;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; Sample(&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; lowerBound, &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; upperBound)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Random&lt;/span&gt; rand = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Random&lt;/span&gt;(1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; lowerBound + rand.NextDouble() * (upperBound - lowerBound);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This implementation defines an input range of [-100.0, 100.0] and is sampling at random inside partitions of this interval.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now we get to the tricky part of this post – we need somehow to cast this into something that is indexable. I touched on the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T,X&amp;gt; &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;class, which we will explore in detail:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;SequenceContainer&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; X : &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;T&amp;gt;, &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; T : &lt;span style=&quot;color: #2b91af;&quot;&gt;IComparable&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Yes, I know, double generics, but unfortunately this is needed when we use the generic &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; interface. The way this works is that T defines the domain type and X is a class type that implements &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; - in other words X is a class implementing a sampler for the domain T. Say we have our class &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainDoubleSampler&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; that implements &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, instantiation of a &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; for this domain type looks like this:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; inputMap = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt; DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainDoubleSampler&lt;/span&gt;&amp;gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now I’m going to jump back to some of the implementation details in the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; indexer class. The following methods help us instantiate our input domain:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;SequenceContainer&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; X : &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;T&amp;gt;, &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; T : &lt;span style=&quot;color: #2b91af;&quot;&gt;IComparable&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; Empty { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt;(); } }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; DomainInput()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;X sampler = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; X();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Add(sampler.Minimum);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Add(sampler.Maximum);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; DomainInput(&lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; clone)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;AddRange(clone);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T, X&amp;gt; Boundary(T b)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; di = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt;(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;di.Add(b);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//di.Add(b.BoundaryNegative()); // Use when Spec Explorer bug is fixed&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//di.Add(b.BoundaryPositive());&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;di.Sort();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; di;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice that constructors are defined&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, and the class is initially instantiated using the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;Empty&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; property. The domain partitioning is then done using &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;Boundary(T b)&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; which returns a new instance of &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;. This allows the following constructor pattern:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;T&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;X&lt;/span&gt;&amp;gt;.Empty.Boundary(B1).Boundary(B2).Boundary(B3);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The boundary values are automatically sorted, so they can be specified in any order. Notice that the &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;Empty&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; property automatically sets up boundary values for domain min and max ranges.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Next up, how do we use this class in our models? Well the implementation is a bit technical, but stay with me:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;SequenceContainer&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; X : &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;T&amp;gt;, &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; T : &lt;span style=&quot;color: #2b91af;&quot;&gt;IComparable&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; NumberOfInputs { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; 2 * Count - 1; } }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; ValidIndex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; index)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; index &amp;gt;= 0 &amp;amp;&amp;amp; index &amp;lt; NumberOfInputs;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; T Input(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; index)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(ValidIndex(index));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (index % 2 == 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Boundary cases: Return boundary value&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.ElementAt(index / 2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Domain cases: Sample domain&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;T lowerBound = &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.ElementAt((index - 1) / 2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;T upperBound = &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.ElementAt((index - 1) / 2 + 1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;X sampler = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; X();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; sampler.Sample(lowerBound, upperBound);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;First, notice that it derives from a &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;SequenceContainer&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;. So our &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; behaves like an immutable container, so you can enumerate elements just like you would a normal container. However, it has the special &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;Input&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; method, which will return either a boundary value (if index is even) or sample from a domain partition between two neighboring boundary values (if index is odd) – sampling domain partitions is done through the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; interface, so this is the reason we had to implement this interface in the first place!&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;As I previously pointed out, you can define any sampling strategy through your custom implementation.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;If you feel like it would be fun to implement this on your own custom boundary, please go ahead and send me your implementation (you can reach me at ‘simon’ dot ‘ejsing’ at ‘microsoft’ dot ‘com‘), and I’ll share it through this blog. Some ideas for input domains: Strings of length 1 to 5, complex numbers, email addresses, URL’s, etc.&lt;/span&gt;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/5914702044168228097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/10/dealing-with-floating-points-in-models.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5914702044168228097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5914702044168228097'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/10/dealing-with-floating-points-in-models.html' title='Dealing with floating points in models - Part II'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-1412060006988742890</id><published>2011-10-14T00:59:00.000-07:00</published><updated>2011-10-14T00:59:23.898-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BST"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><title type='text'>James D. McCaffrey implements Recursive Binary Search Tree</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;Today I came across &lt;/span&gt;&lt;a href=&quot;http://jamesmccaffrey.wordpress.com/2011/09/09/a-quick-and-dirty-binary-search-tree-in-c/&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;this&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; blog article by James D. McCaffrey, where he actually implements a recursive binary search tree, and I couldn’t resist the urge to apply my own Model-Based Testing solution [1,2] to his implementation!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I had to extend his solution a bit to allow for an internal validation function of any constructed tree, but besides from that my only comment to his solution is that he treats error conditions by silently ignore them – that is the following actions generate no errors/exceptions:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;A)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Deleting an element that does not exist in the tree.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;B)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Inserting an element twice into the tree.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Patching these up in his code, my model generated test cases all passed, so his implementation is rock-solid! Kudos for that!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;strong&gt;References:&lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;[1] &lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2011/05/application-of-model-based-testing-to.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Application of Model Based Testing to a Binary Search Tree - Part I&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;[2] &lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2011/05/application-of-model-based-testing-to_27.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Application of Model Based Testing to a Binary Search Tree - Part II&lt;/span&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/1412060006988742890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/10/james-d-mccaffrey-implements-recursive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/1412060006988742890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/1412060006988742890'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/10/james-d-mccaffrey-implements-recursive.html' title='James D. McCaffrey implements Recursive Binary Search Tree'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-8272791893342038769</id><published>2011-10-05T09:59:00.000-07:00</published><updated>2011-10-05T09:59:30.546-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="boundary value"/><category scheme="http://www.blogger.com/atom/ns#" term="domain"/><category scheme="http://www.blogger.com/atom/ns#" term="domain input partitioning"/><category scheme="http://www.blogger.com/atom/ns#" term="double"/><category scheme="http://www.blogger.com/atom/ns#" term="equivalence"/><category scheme="http://www.blogger.com/atom/ns#" term="floating point"/><category scheme="http://www.blogger.com/atom/ns#" term="input"/><category scheme="http://www.blogger.com/atom/ns#" term="integer"/><category scheme="http://www.blogger.com/atom/ns#" term="interface"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="partitioning"/><category scheme="http://www.blogger.com/atom/ns#" term="sampling"/><category scheme="http://www.blogger.com/atom/ns#" term="string"/><title type='text'>Domain input partitioning / dealing with floating points in models – Part I</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Originally I wanted to post everything in one article, but it got too long, so I decided to split it and save the hardcore details for the next post.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;I find that dealing with models involving floating point input can be a tad tricky, so why not post on this topic? The problem here is infinity. It stems from the fact that any given slice of a floating point argument is of infinite size (or at least close to). Often when working with integer models we limit the input variables to a specified range like: &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;where&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; x &lt;span style=&quot;color: blue;&quot;&gt;in&lt;/span&gt; {0..2}&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;. However, this does of course not work if x is a floating point input.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So how &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;do&lt;/i&gt; we deal with infinity? First of all we need to clarify what it is we want. Clearly we do not want to test every possible floating point values between 0 and 2. Also, what we want is determined by what we are testing. So let’s make up an example. Assume we are to test the square root function (of real values to keep it simple), what kind of inputs would we give it? If you are a software tester your testing aptitude should kick-in right about now. We want to try a sunshine scenario with a positive value. We also want to make sure any negative input gives an error and also the boundary case 0 gives an error. Then we also have some extreme ranges like a very large positive number, a large negative number and the maximum and minimum values of the input type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;If we analyze our pattern here, all we are doing is partitioning the input domain. If you have been following this blog for a while you may recall I referenced equivalence class partitioning before – this is the same stuff. Simplifying a bit we end up with an input domain like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiALV5PCCcBpaS09vA1ENX4IwwkxhkYvoVDSzpn7qJdKH1q_0-6w30lQHWT_jNDeM52ogFicMXi-eMVuLcROtT3fVpp3xEk1By3lkeK31KIPLrBc-ovOlre0NBi2SyTI0Xm_ZDj8uUCVWxg/s1600/Domain.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;84&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiALV5PCCcBpaS09vA1ENX4IwwkxhkYvoVDSzpn7qJdKH1q_0-6w30lQHWT_jNDeM52ogFicMXi-eMVuLcROtT3fVpp3xEk1By3lkeK31KIPLrBc-ovOlre0NBi2SyTI0Xm_ZDj8uUCVWxg/s640/Domain.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The important part here is that we have fixed points of interest (the boundaries) and between we have ranges. For the boundary cases, besides the actual boundary value of interest is the near neighbors &lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;±&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Symbol; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Symbol;&quot;&gt;&lt;span style=&quot;mso-char-type: symbol; mso-symbol-font-family: Symbol;&quot;&gt;e&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, where &lt;/span&gt;&lt;span style=&quot;font-family: Symbol; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Symbol;&quot;&gt;&lt;span style=&quot;mso-char-type: symbol; mso-symbol-font-family: Symbol;&quot;&gt;e&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; is a very small number. For the ranges we do not really care what the exact number is, for want of better we draw a random sample from the region.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Note on&amp;nbsp;Spec Explorer and small floating point values:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Unfortunately I found a bug in Spec Explorer, that it crashes when working with small values in floating point. This limits me from trying out combinations where the parameter is &lt;/span&gt;&lt;/i&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Symbol; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Symbol;&quot;&gt;&lt;span style=&quot;mso-char-type: symbol; mso-symbol-font-family: Symbol;&quot;&gt;e&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;. The implementation of the automatic domain partitioning will thus also be limited to testing only at boundary cases and not their near neighbors as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;So, let’s try and reduce this problem to some requirements. Clearly we would like to specify the domain we are working in, this could be integers single/double-precision floating point or even strings! The domain should also have specified a range (our MIN and MAX), and we need the ability to insert boundary values. That pretty much sums it up.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The great thing is that this can be solved using generics! The following interface defines a generic sampler for a domain that fits our specifications:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;interface&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;T Maximum { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;T Minimum { &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;T BoundaryNegative(T boundary);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;T BoundaryPositive(T boundary);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;T Sample(T lowerBound, T upperBound);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In appendix [1] you can find the source code along with implementations of the following domains:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainDoubleSampler&lt;/span&gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainIntegerSampler&lt;/span&gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We need a mechanism for converting an index into a boundary value or domain partition sample; this is handled by the following class:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T, X&amp;gt; : &lt;span style=&quot;color: #2b91af;&quot;&gt;List&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; X : &lt;span style=&quot;color: #2b91af;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&amp;lt;T&amp;gt;, &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; T : &lt;span style=&quot;color: #2b91af;&quot;&gt;IComparable&lt;/span&gt;&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; Empty&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; NumberOfInputs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; DomainInput()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; DomainInput(&lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T,X&amp;gt; clone)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Sort()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; ValidIndex(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; index)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; T Input(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; index)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;T, X&amp;gt; Boundary(T b)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; class is the heavy lifter of the solution; it handles any domain type implementing &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;. Using this implementation you simply call &lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;Input(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; index) &lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;to either return a boundary value or sample from a domain partition.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Applying the DomainInput class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Let’s see how this works in practice. Observe the following model on a &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; domain:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainDoubleSampler&lt;/span&gt;&amp;gt; InputMap = &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainDoubleSampler&lt;/span&gt;&amp;gt;.Empty.Boundary(0.0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; value = 0.0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Compute(x)/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; ComputeRule(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(&lt;span style=&quot;color: #2b91af;&quot;&gt;Accumulator&lt;/span&gt;.InputMap.ValidIndex(x));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;value = &lt;span style=&quot;color: #2b91af;&quot;&gt;Accumulator&lt;/span&gt;.InputMap.Input(x);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Math&lt;/span&gt;.Round(value, 2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Setting up a domain with a boundary value at 0.0 and exploring this tiny model shows off the capabilities of the solution and provides the following input pattern to the Compute method:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX12Ey-XfTX5iFpD6Tjn1knJ7hIgbljtyn44cOGxJSzddd3jjwLmLgVhM7_wZBJwVsuIC-i9Aq8_2rFBs0_ZMkjdA1HpS4Tl3Fls_pxL2p9o6sTe1SVOIGHoED9cnh6y1Lef2-hL9oRW4B/s1600/double100.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;110&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX12Ey-XfTX5iFpD6Tjn1knJ7hIgbljtyn44cOGxJSzddd3jjwLmLgVhM7_wZBJwVsuIC-i9Aq8_2rFBs0_ZMkjdA1HpS4Tl3Fls_pxL2p9o6sTe1SVOIGHoED9cnh6y1Lef2-hL9oRW4B/s640/double100.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Here you can read off that it sampled the following values:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;-100&lt;/b&gt;, -75.13, &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;0&lt;/b&gt;, 24.87, &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;100&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Exactly as we wanted it to! Likewise we can do the same for an integer domain:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainIntegerSampler&lt;/span&gt;&amp;gt; InputMap = &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainIntegerSampler&lt;/span&gt;&amp;gt;.Empty.Boundary(0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfWA7TiFnaKjTVucgQERu6h_go3vYtLla-paqNShWFUuG-aWSp0cyPI8XxXhaFKktpDFMEMXrbIWUrRvGq0TWQGmynDG5AAF7lw2KvEpJSEAN9PnFtZ4OMBScnWBNsIxTz99Xd3u3O9UWl/s1600/int100.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;118&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfWA7TiFnaKjTVucgQERu6h_go3vYtLla-paqNShWFUuG-aWSp0cyPI8XxXhaFKktpDFMEMXrbIWUrRvGq0TWQGmynDG5AAF7lw2KvEpJSEAN9PnFtZ4OMBScnWBNsIxTz99Xd3u3O9UWl/s640/int100.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Now we sample:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;-100&lt;/b&gt;, -23, &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;0&lt;/b&gt;, 77, &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;100&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Or we can include an additional boundary value at 10:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainIntegerSampler&lt;/span&gt;&amp;gt; InputMap = &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainIntegerSampler&lt;/span&gt;&amp;gt;.Empty.Boundary(0).Boundary(10);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFhVcCUlk3C_VL-jxPGDD9erOOYQDvMIyVEfFfnpsKxyDylJUGlB9RIDJLJ-HGQuCD2I2hFZILiWvOlZW5dLgxLDIGOd4KS4uYv6YcpuOrMg91t2TsVYrNybZS3z9ZhI5TAdUiCiyRZdG/s1600/int100-2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;86&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFhVcCUlk3C_VL-jxPGDD9erOOYQDvMIyVEfFfnpsKxyDylJUGlB9RIDJLJ-HGQuCD2I2hFZILiWvOlZW5dLgxLDIGOd4KS4uYv6YcpuOrMg91t2TsVYrNybZS3z9ZhI5TAdUiCiyRZdG/s640/int100-2.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;o:p&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div class=&quot;MsoNoSpacing&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Sampling:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;-100&lt;/b&gt;, -23, &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;0&lt;/b&gt;, 7, &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;10&lt;/b&gt;, 79, &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;100&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice this is just a demo using exploration, normally you would not want to handle the floating point values in the model, here you would base your rules solely on the integer index, and then delegate the floating point conversion to the adapter layer, like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Accumulator&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainDoubleSampler&lt;/span&gt;&amp;gt; InputMap = &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainInput&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt;, &lt;span style=&quot;color: #2b91af;&quot;&gt;DomainDoubleSampler&lt;/span&gt;&amp;gt;.Empty.Boundary(0.0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;double&lt;/span&gt; Compute(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Math&lt;/span&gt;.Sqrt(InputMap.Input(x));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;However, if you need validation to be handled by the model (using return types on rules) you would need to also convert the index to floating point inside the model, just remember to fix the random seed such that the random values sampled are the same between the model and the adapter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Extendibility&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;One thing that is particularly nice about this solution is that it’s extendable through the &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; interface. This means you can extend it to any input domain you like, for example by adjusting the maximum and minimum range of inputs. You can also define your own input domain, one example could be strings following a sequence like: A, B, C, …, Z, AA, AB, … , ZZZZZZZZ – this is a perfectly valid input domain. Also the sampling of partitions is up to you. I used a random sample, but you could also pick the mid-point or any other value inside the partition. All you need to do is implement a sampler for your domain that implements X = &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;IDomainVariableSampler&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;, where T is your primitive input then feed it to &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;DomainInput&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;lt;T,&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;[1] &lt;a href=&quot;http://api.ge.tt/0/9M8OfP8/0/blob/download&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Domain Input Partitioning Model&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/8272791893342038769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/10/domain-input-partitioning-dealing-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/8272791893342038769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/8272791893342038769'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/10/domain-input-partitioning-dealing-with.html' title='Domain input partitioning / dealing with floating points in models – Part I'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiALV5PCCcBpaS09vA1ENX4IwwkxhkYvoVDSzpn7qJdKH1q_0-6w30lQHWT_jNDeM52ogFicMXi-eMVuLcROtT3fVpp3xEk1By3lkeK31KIPLrBc-ovOlre0NBi2SyTI0Xm_ZDj8uUCVWxg/s72-c/Domain.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-8655529381656351300</id><published>2011-10-04T05:18:00.000-07:00</published><updated>2011-10-04T05:18:20.328-07:00</updated><title type='text'>Comments fixed</title><content type='html'>I realized today that comments were not working on my blog.&lt;br /&gt;
&lt;br /&gt;
This should have been fixed now, and you should be able to post anonymous comments!&lt;br /&gt;
&lt;br /&gt;
Sorry for the inconvenience, and please leave a comment to test the site.</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/8655529381656351300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/10/comments-fixed.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/8655529381656351300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/8655529381656351300'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/10/comments-fixed.html' title='Comments fixed'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-3141599987483010586</id><published>2011-09-22T00:24:00.000-07:00</published><updated>2011-09-22T00:25:01.340-07:00</updated><title type='text'>Application of Model-Based Testing to a Stack</title><content type='html'>&lt;span style=&quot;font-family: Calibri;&quot;&gt;Today I would like to go back to basics, and also show how
to easily switch the underlying implementation. Some of my most read posts are
on applying Model-Based Testing to basic data structures, so why not pick up yet
another basic data structure?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;This time I’m keeping it ultra-simple: The Stack.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;I’m sure we all know what a stack is, but to briefly remind
you it’s a LIFO (Last-in, first-out) container. In a classic stack elements are
added on top of the stack using the “Push” command and removed from the top
one-by-one using “Pop”. When an element is popped it is removed from the stack
and returned. It is not possible to reference elements that are not on the top
of the stack.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;A not-so-classic stack variation contains a “Peek” function
that will return the top element of the stack without removing it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;So without further ado let’s jump into modeling!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Implementation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;For the purpose of this post I’ve re-implemented the wheel
and written a fixed-size (10) integer based stack:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;
&lt;span style=&quot;color: #2b91af;&quot;&gt;Stack&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;[]
items = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;[10];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
count = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;
Stack()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Push(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(count &amp;gt;= items.Length)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;throw&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Stack overflow&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;
(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = count; i &amp;gt; 1; i--)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;items[i] = items[i-1];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;items[count++] = x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; Peek()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;
items[0];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; Pop()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(count &amp;lt;= 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;throw&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Popping empty stack&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
x = items[0];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; count; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;items[i] = items[i+1];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;count--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;
x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Pretty standard stuff.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Model&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;For modeling the stack we define the three actions and model
them like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;StackModel&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;SequenceContainer&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt; inputSequence = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;
&lt;span style=&quot;color: #2b91af;&quot;&gt;SequenceContainer&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;new this.Stack()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;StackModel()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;this.Push(x)&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;
PerformPush(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(inputSequence.Count
&amp;lt; 4);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;inputSequence.Add(x);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;this.Peek()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
PerformPeek()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(inputSequence.Count
&amp;gt; 0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;
inputSequence[inputSequence.Count - 1];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;this.Pop()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
PerformPop()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(inputSequence.Count
&amp;gt; 0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
x = inputSequence[inputSequence.Count - 1];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;inputSequence.RemoveAt(inputSequence.Count - 1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;
x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;In the config.cord script I have limited the input values for
the “Push” action to 0 and 1. Also the model is limited to having at most 3
elements in the stack at any given time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Exploration of this model yields:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig9IVVreYmTyBqNWcQpXacgKdSZMZJ7u7nFn3GsC1vfjuQ4mqZT8NwtwWNvvByN7AGsW5TkLhDxfEVcpcjn20KFtP_sHZO2BW5oUJ1IDudEKvNRiBO0uCrvEvE5zQ56qW_0Mr4j-Rddtqj/s1600/model.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig9IVVreYmTyBqNWcQpXacgKdSZMZJ7u7nFn3GsC1vfjuQ4mqZT8NwtwWNvvByN7AGsW5TkLhDxfEVcpcjn20KFtP_sHZO2BW5oUJ1IDudEKvNRiBO0uCrvEvE5zQ56qW_0Mr4j-Rddtqj/s640/model.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;
 &lt;v:stroke joinstyle=&quot;miter&quot;&gt;
 &lt;v:formulas&gt;
  &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;
  &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;
  &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;
  &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;
  &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;
  &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;
  &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;
  &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;
 &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;
 &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;
 &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt;
&lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Test cases&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;There’s an interesting fact about our model. Because every
state is connected to all other states, traversing the graph with the “Long tests”
strategy will yield only one test case. I don’t like this, so I’m going to
change it to use “Short tests” strategy instead.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The generated test cases are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJKz7cfpP1RBQbFGy1970VdYbhuqF-ouDxTgHHl84e05ov3q-1i3FdBNY2HTy1fvX4_J4-eCwMjC_a-UPOKJHduLQa0FL-fjXJpF_ZXpyGyotOpeqW8u6pFk_s2eU5Ye8nVZR4aZf7uqIW/s1600/tests.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;104&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJKz7cfpP1RBQbFGy1970VdYbhuqF-ouDxTgHHl84e05ov3q-1i3FdBNY2HTy1fvX4_J4-eCwMjC_a-UPOKJHduLQa0FL-fjXJpF_ZXpyGyotOpeqW8u6pFk_s2eU5Ye8nVZR4aZf7uqIW/s640/tests.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;An interesting fact is that I found two bugs in my
implementation of the stack when running these generated tests (that tells you a
bit about my coding skills – it’s a good thing I’m hired as a tester...):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 38.4pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;
&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Off by one error in the loop that shifts elements
out&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 0pt 38.4pt; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;
&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Push was inserting new elements at the bottom of
the stack&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;
(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = count; i &amp;gt; &lt;span style=&quot;background: red; mso-highlight: red;&quot;&gt;1&lt;/span&gt;; i--)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;items[i] = items[i-1];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;items[&lt;span style=&quot;background: red; mso-highlight: red;&quot;&gt;count++&lt;/span&gt;] = x;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;I left the bugs in the sample, which you by the way can find
in the reference list [1].&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Testing .NET class
libraries&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Okay, so now we have tested that our stack implementation is
not working, let’s try something funny! So .NET contains an implementation of a
stack in System.Collections.Stack, wouldn’t it be interesting to check that the
guys in .NET did a better job than me implementing a stack? Actually, SpecExplorer
allows us to test any .NET class directly. We simply change the using
declaration in the config.cord file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;
System.Collections;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; font-size: 9.5pt;&quot;&gt;//using StackModel.Sample;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;And the type binding in the StackModel.cs file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;TypeBinding&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;System.Collections.Stack&quot;&lt;/span&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;color: green; font-family: Consolas; font-size: 9.5pt;&quot;&gt;//[TypeBinding(&quot;StackModel.Sample.Stack&quot;)]&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;And re-generate our test suite. The model obviously stays
the same (we didn’t change that) but the tests will now call into the .NET
stack class implementation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;But wait a minute? We implemented an integer based stack,
and the .NET stack holds any objects, then why does this work? It turns out
that because the interface for our stack is a subset of that of the more
generic .NET stack class, SpecExplorer can automatically cast the arguments
from integers to Objects, and everything works out-of-the-box! That is pretty
sweet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Big surprise, running the generated test cases, they all
pass! Kudos to the .NET guys for a good job, and I think I will stay on the
testing path for now &lt;/span&gt;&lt;span style=&quot;font-family: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;&quot;&gt;&lt;span style=&quot;mso-char-type: symbol; mso-symbol-font-family: Wingdings;&quot;&gt;J&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;And finally I would really appreciate some feedback, so if you made it all the way down&amp;nbsp;here, please leave a comment telling me what you think was good/bad about this post - thanks!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;References&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;[1] &lt;/span&gt;&lt;a href=&quot;http://api.ge.tt/0/9dQfo18/0/blob/download&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Stack
Model&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/3141599987483010586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/09/application-of-model-based-testing-to.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/3141599987483010586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/3141599987483010586'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/09/application-of-model-based-testing-to.html' title='Application of Model-Based Testing to a Stack'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig9IVVreYmTyBqNWcQpXacgKdSZMZJ7u7nFn3GsC1vfjuQ4mqZT8NwtwWNvvByN7AGsW5TkLhDxfEVcpcjn20KFtP_sHZO2BW5oUJ1IDudEKvNRiBO0uCrvEvE5zQ56qW_0Mr4j-Rddtqj/s72-c/model.JPG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-5625647921603353295</id><published>2011-09-06T04:07:00.000-07:00</published><updated>2011-09-06T04:07:15.337-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="accepting condition"/><category scheme="http://www.blogger.com/atom/ns#" term="barrier"/><category scheme="http://www.blogger.com/atom/ns#" term="concurrent"/><category scheme="http://www.blogger.com/atom/ns#" term="instance based"/><category scheme="http://www.blogger.com/atom/ns#" term="invariant"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="modeling"/><category scheme="http://www.blogger.com/atom/ns#" term="multi-threaded"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="synchronization"/><title type='text'>Multi-Threaded Modeling – Barrier Synchronization</title><content type='html'>

&lt;span style=&quot;font-family: Calibri;&quot;&gt;Okay, all my previous posts have been based on static system
models, where rules and actions are static functions in classes. A lot can be
accomplished with this, and it is also possible to wrap instance based
applications inside static functions. However, Spec Explorer allows us to work
with actual instance based models.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;

&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;So what does this mean for us? Well, it means we are allowed
to instantiate any number of objects of some type and Spec Explorer can
reference each of these objects individually. For example, you could write a
class that represents a complex number, and have Spec Explorer create two instances
of this object and then add them together. This would be a basic example, but
instead let’s jump to something more tricky – multi-threading!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;You can imagine that instance based modeling and multi-threading
are closely related. But there are some key issues one must understand first. Instance
based modeling is &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;not&lt;/i&gt; multi-threaded,
it is exactly as sequential as any static model. Spec Explorer will not create
a new thread for you when you instantiate an object. Any interaction by Spec
Explorer will be from the “main”-thread, you have to handle communication with
your threads.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Barrier
synchronization&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The example I have picked for this post is a barrier
synchronization implementation. Barrier synchronization is a pattern for worker
threads in multi-threaded application. With barrier synchronization each thread
must wait for its co-workers to complete their cycle of work before the next
cycle starts. Denoting the number of cycles completed by thread &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;i&lt;/i&gt; as &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;c&lt;sub&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;i&lt;/span&gt;&lt;/sub&gt;&lt;/i&gt;,
this can be stated by the following invariant:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-theme-font: minor-fareast;&quot;&gt;&lt;span style=&quot;mso-tab-count: 1;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDE_zJ6R9RvOB97F8xmHqnkGR7F-CpoU6cBOr_fHExRaMQ1uw1Dt7N_5hWbjCYLoyDZ0iN1UzGG-tR7uj111e2NZ-C3JAu1nLEI0MEBQRkM0AzTuTsS3lTDL9tMM6rIYFf9j6SsiotTVAk/s1600/Equation.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDE_zJ6R9RvOB97F8xmHqnkGR7F-CpoU6cBOr_fHExRaMQ1uw1Dt7N_5hWbjCYLoyDZ0iN1UzGG-tR7uj111e2NZ-C3JAu1nLEI0MEBQRkM0AzTuTsS3lTDL9tMM6rIYFf9j6SsiotTVAk/s1600/Equation.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Essentially each thread reaches a “barrier” upon completion
of its work. This “barrier” is only lowered once all threads have reached it. Upon
release of the “barrier” the worker threads continues their work.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;


&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Implementation of
barrier synchronization&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;First of all, we capture the threading in a class&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;BarrierThread&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Thread&lt;/span&gt;
thread;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;
abortOnSynchronize = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;volatile&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; workCycles = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;volatile&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; abort = &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;
BarrierThread()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;thread = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;
&lt;span style=&quot;color: #2b91af;&quot;&gt;Thread&lt;/span&gt;(() =&amp;gt; ThreadMain());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Start()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;thread.Start();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; ThreadMain()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;do&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;} &lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt;
(!abort);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; Synchronize()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;...&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;There are a couple of things to point out here. I’ve cut
away the tricky implementation details at first, but essentially the
constructor spawns a new thread which can be started with a call. This thread
goes into a loop until aborted. Notice there is a couple of variables that are
declared volatile to avoid compiler optimization around these – this is
important because they are shared between the main thread and the worker
threads!&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The difficult parts of the implementation are the thread
body, synchronization and abortion, but I’m not going into detail with that right
now, you can refer to the sample [1].&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Modeling barrier
synchronization&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Before I go on to
describe the model a word of warning is in place. The config.cord file is very
different from that of a static model, but I don’t want to dwell on that – I may
do a follow up post on this if I find the time for it.&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;For my implementation the threads are modeled with the
following interface:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;enum&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadState&lt;/span&gt; { Unstarted, Started, Aborting,
Aborted };&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Starts the
worker thread&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;this.Start()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;
Start()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Aborts the
worker thread upon next synchronization&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;this.Abort()&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;
Abort()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Barrier
synchronization of all worker threads, returns the current worker thread cycle
count&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;this.Synchronize()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
Synchronize()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The &lt;/span&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;ThreadState&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; enum enumerates the states our threads can be
in from the model perspective. The &lt;em&gt;Start&lt;/em&gt; and &lt;em&gt;Abort&lt;/em&gt; rules just change current thread
state. Threads that are aborted will be set to an intermediate state for actual
abortion upon next synchronization.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;It should be noted that each rule in the model applies to &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;any&lt;/i&gt; instance of our class. This means
that the model exploration will call &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;Start&lt;/i&gt;,
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;Abort&lt;/i&gt; and &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;Synchronize&lt;/i&gt; on any instance. This is important to understand,
because if all threads jump into the synchronization rule they will hang
waiting on each other. The implementation details of the synchronization rule
are:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Barrier
synchronization of all worker threads, returns the current worker thread cycle
count&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action
= &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;this.Synchronize()/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;
Synchronize()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(synchronizations++
&amp;lt; 3);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; threads.Count; i++) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(threads[i]
!= &lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadState&lt;/span&gt;.Unstarted);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(threads[i]
!= &lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadState&lt;/span&gt;.Aborted);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(threads[i] == &lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadState&lt;/span&gt;.Aborting)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;threads[i] = &lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadState&lt;/span&gt;.Aborted;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;
synchronizations;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;First we are limiting the number of working cycles to
perform to 3. Notice that synchronization is not allowed before all worker
threads are started or aborting, this is essential, because otherwise the main
thread will be hanging unable to start all workers. This is an example of where
we need to remember that model exploration is sequential.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is all there is to the model. With two threads exploration
yields:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZXq81L_JcaXzaAA97Gj4c_1TZWKU9ALi1G5DwxrSwtJ7XumPFo7bxd-z3RLPwM2OkTwCvLl90OWjkmwg4ER9XfjndP6rNsVSjUqUtmpNKRjTRLFfYJy8Gqx9mEIfer1PCSfQavA7QfQCt/s1600/2-thread+model.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;154&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZXq81L_JcaXzaAA97Gj4c_1TZWKU9ALi1G5DwxrSwtJ7XumPFo7bxd-z3RLPwM2OkTwCvLl90OWjkmwg4ER9XfjndP6rNsVSjUqUtmpNKRjTRLFfYJy8Gqx9mEIfer1PCSfQavA7QfQCt/s640/2-thread+model.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;span style=&quot;mso-no-proof: yes;&quot;&gt;&lt;v:shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;
 &lt;v:stroke joinstyle=&quot;miter&quot;&gt;
 &lt;v:formulas&gt;
  &lt;v:f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;
  &lt;v:f eqn=&quot;sum @0 1 0&quot;&gt;
  &lt;v:f eqn=&quot;sum 0 0 @1&quot;&gt;
  &lt;v:f eqn=&quot;prod @2 1 2&quot;&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;
  &lt;v:f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;
  &lt;v:f eqn=&quot;sum @0 0 1&quot;&gt;
  &lt;v:f eqn=&quot;prod @6 1 2&quot;&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;
  &lt;v:f eqn=&quot;sum @8 21600 0&quot;&gt;
  &lt;v:f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;
  &lt;v:f eqn=&quot;sum @10 21600 0&quot;&gt;
 &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;
 &lt;v:path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;
 &lt;o:lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt;
&lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;One problem with the model/implementation is that you can
abort one thread while the other is still active. The implementation does not
accurately track that the number of threads decreased, as such this is not
allowed and our implementation would run into deadlock in case this happens. Also,
if one or more threads are not aborted upon test completion the test will hang
because remaining threads have not terminated.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The way we handle this is simply
to state that states are only acceptable if all threads have been aborted in
the end:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;// Accept
only end states where all threads are aborted&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;AcceptingStateCondition&lt;/span&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;
Accepting()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;
(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; threads.Count; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;
(threads[i] != &lt;span style=&quot;color: #2b91af;&quot;&gt;ThreadState&lt;/span&gt;.Aborted)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;When generating test cases we can filter to only end-states
that are accepting states.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Test generation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The test generation is filtered to only accepting end-states
using:&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;color: blue; font-family: Consolas; font-size: 9.5pt;&quot;&gt;machine&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;
ThreadTestSuite() : Main &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; TestEnabled = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;construct&lt;/span&gt;
test cases &lt;span style=&quot;color: blue;&quot;&gt;where&lt;/span&gt; strategy = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;longtests&quot;&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;construct&lt;/span&gt;
accepting paths &lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; Sliced2ThreadModelProgram()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The key word here is the “accepting paths” construct. This
is pretty nice, because we can keep the model showing that it has this “flaw”,
while still generating only tests that we know satisfy our conditions for the
implementation (i.e. abort all threads before finishing).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;The generated test cases are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv7WZar0lP9_tFwjgG4NC6Pp09F9D7dvJkCqQeRgTtOdeLWL2K3t4jioK8yN_xDQ31EmJsDe0JGxi16O9FCu0zAeAv2gFKiUwT0HjUUjlG-7PRafbzb190F-SudTgYfVTlTbpjXO8ZPiWj/s1600/2-thread+accepting+tests.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;202&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv7WZar0lP9_tFwjgG4NC6Pp09F9D7dvJkCqQeRgTtOdeLWL2K3t4jioK8yN_xDQ31EmJsDe0JGxi16O9FCu0zAeAv2gFKiUwT0HjUUjlG-7PRafbzb190F-SudTgYfVTlTbpjXO8ZPiWj/s640/2-thread+accepting+tests.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Running concurrent
tests&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;When running concurrent tests, one type of bugs we are
looking for is deadlocks. The problem is of course that in this case the test
case will hang until it times out. It is a good idea to decrease the test
timeout to a small value. In my case I’m decreasing it to 10 seconds as this is
sufficient time for my tests to complete.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Doing so requires that you add a testsettings file. This is
done from right-clicking the solution and adding a new item. It took me a while
to figure this out, as I was trying to add it to the test project at first, but
this is not possible.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;Although instance based modeling is the way to go when
testing concurrent systems, care has to be put into designing the adapter
layer. From my experience developing this sample model you will run into
situations where the generated tests deadlocks. In many cases this is due to
implementation issues, but getting the model right is also tricky. Fortunately
a lot of headaches can be avoided by filtering invalid states out, like I did
for cases where some threads were left running. In this respect model based
testing is actually a very powerful tool for writing concurrent test scenarios.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Calibri;&quot;&gt;[1] &lt;/span&gt;&lt;a href=&quot;http://api.ge.tt/0/8gIu2U7/0/blob/download&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;Barrier
synchronization model&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/5625647921603353295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/09/multi-threaded-modeling-barrier.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5625647921603353295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/5625647921603353295'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/09/multi-threaded-modeling-barrier.html' title='Multi-Threaded Modeling – Barrier Synchronization'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDE_zJ6R9RvOB97F8xmHqnkGR7F-CpoU6cBOr_fHExRaMQ1uw1Dt7N_5hWbjCYLoyDZ0iN1UzGG-tR7uj111e2NZ-C3JAu1nLEI0MEBQRkM0AzTuTsS3lTDL9tMM6rIYFf9j6SsiotTVAk/s72-c/Equation.PNG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5763920051047304998.post-4379413597617193273</id><published>2011-08-21T12:48:00.000-07:00</published><updated>2011-08-21T12:48:35.261-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="acceptance scenarios"/><category scheme="http://www.blogger.com/atom/ns#" term="agile"/><category scheme="http://www.blogger.com/atom/ns#" term="design changes"/><category scheme="http://www.blogger.com/atom/ns#" term="discussions"/><category scheme="http://www.blogger.com/atom/ns#" term="explicit"/><category scheme="http://www.blogger.com/atom/ns#" term="implicit"/><category scheme="http://www.blogger.com/atom/ns#" term="model based testing"/><category scheme="http://www.blogger.com/atom/ns#" term="requirements"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><category scheme="http://www.blogger.com/atom/ns#" term="scrum"/><title type='text'>Model-Based Testing in Agile Development Cycles – Part II</title><content type='html'>  &lt;span style=&quot;font-family: Calibri;&quot;&gt;Last post I left you hanging after a model had emerged from our initial acceptance requirements. The model we generated looked like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMfiTXmSvB85cN0H9x-s2oZGtmxJHnNpU_G7ui6oviix7CihrY4gNDHBBsCxwXCExv9MUrpGDsqhiCiAPHT3ZQxrMjEwcImBFBDpKAGC_DtfKLa59IjV2pIX4luuo6_n_v0GUMFzbY6296/s1600/model+unlimited+reversal.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;492&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMfiTXmSvB85cN0H9x-s2oZGtmxJHnNpU_G7ui6oviix7CihrY4gNDHBBsCxwXCExv9MUrpGDsqhiCiAPHT3ZQxrMjEwcImBFBDpKAGC_DtfKLa59IjV2pIX4luuo6_n_v0GUMFzbY6296/s640/model+unlimited+reversal.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Today’s post is about what you can use this model for in agile development, and what kind of test cases it produces.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Design discussions&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;As I already pointed out in the previous post, models are great in discussions. Often when you explain the model to the product owner he/she will start noticing quirks. For the example model we developed, one such quirk is that the system is not allowed to reverse a payment if said payment has been involved in a financial application. Although it is a requirement in the system, it was not mentioned in the acceptance criteria because it is not a sun-shine scenario. Design discussions based on models will help you uncover these &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;implicit&lt;/i&gt; requirements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;It’s easy to solve these quirks when you are at the modeling stage, whereas maintaining traditional scenario based tests can require a lot of effort when requirements change. A benefit from modeling in Agile is that you uncover these implicit requirements early in the development cycle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;In our case we can fix the problem either by adjusting the model to avoid taking the ReversePayment action from states where the payment has been involved in a financial application. But more often than not, we would actually like to have a test case that checks that this implicit requirement is working – that is we would like the model to actually try doing it, but to expect a failure. We update the rule to:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style=&quot;color: #2b91af;&quot;&gt;Rule&lt;/span&gt;(Action = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;ReversePayment/result&quot;&lt;/span&gt;)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt; ReversePayment()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;Condition&lt;/span&gt;.IsTrue(Entries &amp;gt; 0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (Applications &amp;gt; 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Entries--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt;&lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Two things happen&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;a)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The return value of ReversePayment from the model rule is matched against the return value of the adapter layer when executing tests.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;b)&lt;/span&gt;&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font: 7pt/normal &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The state space will not change if financial applications exist, making the rule a self-looping action.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Our new model looks like:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG1rpF0Mc9Dg1dZT9XaIBh2WN3U17jsKr0Yfnp2m-5abwjV82HlC1bSJhL9g4c6RGZE_-KEhpzSuhp1ClMA5sBTNxNy0Qg3iuigyfC0hhLxL82J4L1dfdyluewzAqvX8V9C9nUKY9NHD0h/s1600/model+limited+reversal.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;448&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG1rpF0Mc9Dg1dZT9XaIBh2WN3U17jsKr0Yfnp2m-5abwjV82HlC1bSJhL9g4c6RGZE_-KEhpzSuhp1ClMA5sBTNxNy0Qg3iuigyfC0hhLxL82J4L1dfdyluewzAqvX8V9C9nUKY9NHD0h/s640/model+limited+reversal.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Notice how the return value of the ReversePayment rule differs between state S4 and S8, and how the latter is a self-looping action. This is of course because in state S8 the payment is involved in a financial application. Because we modeled the return code we will see that the test generation will construct scenarios where we test the implicit requirement is enforced by the system.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Tests&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Okay, enough design discussions. Let’s look at the actual outcome! Exploring the test case generation we find:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUPOMrnFyskXmgE1SUlph3NS0W_nKsw3vEd4bRe_FspGw6BsvBAovVRq7mzKWknKFvz5GbhXZe1lkOcOWOy-go1TCdFHSfofT7zr4Of8hIESFk71QZqjiupnWIniPwlyUvrptTb-GvQ_Km/s1600/tests.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUPOMrnFyskXmgE1SUlph3NS0W_nKsw3vEd4bRe_FspGw6BsvBAovVRq7mzKWknKFvz5GbhXZe1lkOcOWOy-go1TCdFHSfofT7zr4Of8hIESFk71QZqjiupnWIniPwlyUvrptTb-GvQ_Km/s640/tests.JPG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;What you immediately notice is that we recover our 4 original acceptance scenarios (encircled in orange). I encourage you to go back to &lt;/span&gt;&lt;a href=&quot;http://appmbt.blogspot.com/2011/08/model-based-testing-in-agile.html&quot;&gt;&lt;span style=&quot;color: blue; font-family: Calibri;&quot;&gt;part I&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt; and check the scenarios match. We also find tests covering our implicit requirement. In total we got 11 test cases out of the model even though it was built from just 4 acceptance tests. So not only should you find all your acceptance scenarios in the generated test suite, but you should expect that the model does a more thorough job as well! Actually, if you find that not all of your acceptance criteria are represented by the generated test cases, you should go back and revisit your model to look for any bugs in the design.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Not only does the model serve as a great input to design discussions, it will also automatically produce all your acceptance scenarios. That means when the model adapter layer and the feature you are testing are complete, you simply run your Model-Based test suite as your acceptance criteria.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://appmbt.blogspot.com/feeds/4379413597617193273/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://appmbt.blogspot.com/2011/08/model-based-testing-in-agile_21.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/4379413597617193273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5763920051047304998/posts/default/4379413597617193273'/><link rel='alternate' type='text/html' href='http://appmbt.blogspot.com/2011/08/model-based-testing-in-agile_21.html' title='Model-Based Testing in Agile Development Cycles – Part II'/><author><name>Simon Ejsing</name><uri>http://www.blogger.com/profile/06167662704783766614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_CNAsmlMHwwvnooH-P00Z8mkDJUrz5L7MHo1kYXs6GHnhgoZszpFVrB8wtsQRq0LIBK85h_bORGvoOS5XEDeRKJ6w5f_62VoOK8zD3pOYGLR7KXXzNHpwWdYfHxvKgg/s220/Simon+Ejsing.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMfiTXmSvB85cN0H9x-s2oZGtmxJHnNpU_G7ui6oviix7CihrY4gNDHBBsCxwXCExv9MUrpGDsqhiCiAPHT3ZQxrMjEwcImBFBDpKAGC_DtfKLa59IjV2pIX4luuo6_n_v0GUMFzbY6296/s72-c/model+unlimited+reversal.JPG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>