<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Siliconcreek.net: The Blog of Andrew Rohne &#187; four step model</title>
	<atom:link href="http://www.siliconcreek.net/tag/four-step-model/feed" rel="self" type="application/rss+xml" />
	<link>http://www.siliconcreek.net</link>
	<description>This is the unfiltered personal website of Andrew Rohne, expert Cube Voyager user, transportation planner, engineer, programmer, ham radio operator, and all-around geek.</description>
	<lastBuildDate>Fri, 30 Sep 2011 14:37:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using a C++ DLL in Cube</title>
		<link>http://www.siliconcreek.net/transportation/using-a-c-dll-in-cube</link>
		<comments>http://www.siliconcreek.net/transportation/using-a-c-dll-in-cube#comments</comments>
		<pubDate>Sun, 10 Oct 2010 13:00:20 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Transportation]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[cube voyager c++]]></category>
		<category><![CDATA[four step model]]></category>
		<category><![CDATA[tdm]]></category>
		<category><![CDATA[tour-based-modeling]]></category>
		<category><![CDATA[voyager]]></category>

		<guid isPermaLink="false">http://www.siliconcreek.net/?p=584</guid>
		<description><![CDATA[One thing that can drastically speed Cube is using a DLL to do big tasks, like Nested Logit Mode Choice. However, doing this can be fraught with hair-pulling errors.  This post shows some techniques to keep your hair on your head.  This post is written for a travel demand modeler, not a computer science person! [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that can drastically speed Cube is using a DLL to do big tasks, like Nested Logit Mode Choice.  However, doing this can be fraught with hair-pulling errors.  This post shows some techniques to keep your hair on your head.  This post is written for a travel demand modeler, not a computer science person!</p>
<h3>RTFM (Read The Fine Manual)</h3>
<p>Read the help file for Matrix CALL statement.  The struct statement is pretty important, and the sprintf lines will be used throughout.</p>
<h3>Memory Pointers</h3>
<p>One of the most important things to understand is that because there are so many variables that can be passed between Cube and the C++ DLL, the memory pointers are passed instead.  Also, one of those &#8220;pull your hair out&#8221; things relates to this &#8211; if you attempt to access a memory pointer that hasn&#8217;t been initialized, you get a crash that gives no error.</p>
<p>Because of this, the variables in the struct statement have a *, which notes that it is a memory pointer.</p>
<p>To keep from getting the crash-with-no-error, the following statement works well to test and allows a default to be used if the variable &#8216;MarketSegments&#8217; is not set in Cube.</p>
<pre class="brush:c++">int MarketSegments=4;

if(Stack-&gt;pfFindVar("MarketSegments")!=0)
MarketSegments=(int)*Stack-&gt;pfFindVar("MarketSegments");</pre>
<h3>Matrix In, Matrix Out</h3>
<p>While the Help file says that you can get to defined working matrixes using</p>
<pre class="brush:c++">static double **MW;
MW=(*Stack-&gt;pfFindVar)("MW",1);</pre>
<p>I can&#8217;t get it to work using C++ (I have gotten it to work in C).  Instead, use the following:</p>
<pre class="brush:c++">static double **MW=NULL;
MW=Stack-&gt;MW;</pre>
<p>This will enable you to use MW[m][j] (where m is the MW number, and j is the j-zone).</p>
<p>You can also set the MW variables, but it does NOTHING if you don&#8217;t set the MW to something in Cube Voyager.  Ergo, if you set</p>
<pre class="brush:c++">MW[101][j]=10;</pre>
<p>Your output will be 0 unless you do the following in Cube Voyager</p>
<p><code>MW[101]=0<br />
CALL...</code></p>
<h3>Array Variables</h3>
<p>One of the tricks I use to get array variables out of Cube is this</p>
<pre class="brush:c++">float ArrayVariable[7]={0,0,0,0,0,0,0};  //Note: I'm using 1-6.  Setting this to 7 means 0-6.  Setting it to 6 would mean 0-5
if(Stack-&gt;pfFindVar("ArrayVariable")&gt;0){
double* tmpAV=NULL;
tmpAV=Stack-&gt;pfFindVar("ArrayVariable",1,2,3,4,5,6);
for(int x=1;x&lt;=6;x++)
ArrayVariable[x]=tmpAV[x];
}</pre>
<p>This code above checks that the ArrayVariable, fills them into a temporary variable, and then sets the actual variable.</p>
<h3>Compilation Linker Settings</h3>
<p>When compiling, you need to set the EXPORT flag so the name is predictable and correct.  To do this, go to your project&#8217;s property pages &#8211; Configuration Properties &#8211; Linker &#8211; Command Line.  You need to add &#8220;/EXPORT:FunctionName&#8221; under Additional Options.  See the screenshot below</p>
<p>.<img class="alignnone size-medium wp-image-590" title="Linker Settings" src="http://www.siliconcreek.net/wordpress/wp-content/uploads/2010/10/Clip-1-300x212.png" alt="" width="300" height="212" /></p>
<h3>Other Weird Stuff</h3>
<p>Any error in C++ that does not cause a compilation error results in one of those useless &#8220;this program has an error and will be closed&#8221; and crashes Task Monitor.  That being said, write messages to the output file frequently (if at least during debugging).  This can assist with finding typos (like, say, %10.65f in an sprintf statement, which means 65 decimal places in a 10-width line).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.siliconcreek.net/transportation/using-a-c-dll-in-cube/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cube Voyager: Using Cluster with DBI</title>
		<link>http://www.siliconcreek.net/transportation/cube-voyager-using-cluster-with-dbi</link>
		<comments>http://www.siliconcreek.net/transportation/cube-voyager-using-cluster-with-dbi#comments</comments>
		<pubDate>Sun, 03 Oct 2010 13:00:12 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Transportation]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[cube]]></category>
		<category><![CDATA[DBI]]></category>
		<category><![CDATA[four step model]]></category>
		<category><![CDATA[tdm]]></category>
		<category><![CDATA[tour-based-modeling]]></category>
		<category><![CDATA[trip-based-modeling]]></category>
		<category><![CDATA[voyager]]></category>

		<guid isPermaLink="false">http://www.siliconcreek.net/?p=580</guid>
		<description><![CDATA[Credit for this goes to Citilabs Support, although I made some adaptations. In Matrix when using DBI, PAR ZONES=1 will effectively shut off Cluster. Therefore, the following works really well. DISTRIBUTEINTRASTEP ProcessID=Cluster ProcessList={CORES} PAR ZONES={CORES} recs = ROUND(DBI.1.NUMRECORDS/{CORES}) start = (I-1)*recs+1 IF (I={CORES}) end = DBI.1.NUMRECORDS ELSE end = I*recs ENDIF LOOP _r=start,end x=DBIReadRecord(1,_r) ENDLOOP [...]]]></description>
			<content:encoded><![CDATA[<p>Credit for this goes to Citilabs Support, although I made some adaptations.</p>
<p>In Matrix when using DBI, PAR ZONES=1 will effectively shut off Cluster.  Therefore, the following works really well.</p>
<p><code><br />
DISTRIBUTEINTRASTEP ProcessID=Cluster ProcessList={CORES}</p>
<p>PAR ZONES={CORES}</p>
<p>recs = ROUND(DBI.1.NUMRECORDS/{CORES})<br />
start = (I-1)*recs+1<br />
IF (I={CORES})<br />
end = DBI.1.NUMRECORDS<br />
ELSE<br />
end = I*recs<br />
ENDIF</p>
<p>LOOP _r=start,end<br />
x=DBIReadRecord(1,_r)<br />
ENDLOOP<br />
</code></p>
<p>This script sets each core to process an equal portion of the database with any remainder (e.g if you cluster 4 records over 3 cores) to the last core.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.siliconcreek.net/transportation/cube-voyager-using-cluster-with-dbi/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cube Voyager Speed Clinic</title>
		<link>http://www.siliconcreek.net/transportation/cube-voyager-speed-clinic</link>
		<comments>http://www.siliconcreek.net/transportation/cube-voyager-speed-clinic#comments</comments>
		<pubDate>Sun, 26 Sep 2010 16:33:02 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Transportation]]></category>
		<category><![CDATA[cube]]></category>
		<category><![CDATA[four step model]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[tdm]]></category>
		<category><![CDATA[tour-based-modeling]]></category>
		<category><![CDATA[trip-based-modeling]]></category>
		<category><![CDATA[voyager]]></category>

		<guid isPermaLink="false">http://www.siliconcreek.net/?p=570</guid>
		<description><![CDATA[There are several issues with long travel demand model run times.  Deep down, these are supposed to be planning tools, and taking too long for results can reduce the practicality of using a travel demand model in decision making. In Cube Voyager, I&#8217;ve been finding more ways to cut runtimes down as much as possible, [...]]]></description>
			<content:encoded><![CDATA[<p>There are several issues with long travel demand model run times.  Deep down, these are supposed to be planning tools, and taking too long for results can reduce the practicality of using a travel demand model in decision making.</p>
<p>In Cube Voyager, I&#8217;ve been finding more ways to cut runtimes down as much as possible, and below is the list with some of the rationale.</p>
<h3>Keep JLoops at a Minimum</h3>
<p>The Matrix program runs in an implied ILOOP.  This being the case, anything in the script runs many times (as many as the zones you have).  Using a JLOOP in a 2,000 zone model means that there are  4,000,000 calculations to be done for each COMP statement.  What happens if you have 3 COMP statements?  You go from 4,000,000 to 12,000,000 calculations.  This is even worse if the calculations include a lookup function, which are generally slow.</p>
<h3>Keep Files Small &#8211; Only Write What You Have To</h3>
<p>This is a no-brainer.  The more that Cube (or anything, for that matter) has to write to disk, the longer the runtime.</p>
<h3>Replace RECI with DBI wherever possible</h3>
<p>DBI can be clustered (look for a post on that in the coming weeks).  While I&#8217;m not sure if there is any difference on one core, being able to use Cluster is the trump card.</p>
<h3>Use Cluster Dynamically and Wherever Possible</h3>
<p>Standardize the Cluster ID in your code, but set the process list to a catalog key as with below:</p>
<p><code>DISTRIBUTEINTRASTEP CLUSTERID=Cluster PROCESSLIST=2-{CORES}</code></p>
<p>Using Cluster to your advantage is critical to having a fast model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.siliconcreek.net/transportation/cube-voyager-speed-clinic/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Travel Demand Modeling 101 Part 1: Terminology</title>
		<link>http://www.siliconcreek.net/transportation/travel-demand-modeling-101-part-1-terminology</link>
		<comments>http://www.siliconcreek.net/transportation/travel-demand-modeling-101-part-1-terminology#comments</comments>
		<pubDate>Sat, 23 Aug 2008 02:53:14 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Transportation]]></category>
		<category><![CDATA[four step model]]></category>

		<guid isPermaLink="false">http://www.siliconcreek.net/?p=174</guid>
		<description><![CDATA[It occurred to me that many people likely do not understand all of the terminology of travel demand models.  Because of this, I felt the need to list many of them here. Assignment: A process that determines the specific route of travel from one zone to another. Binomial Logit Mode Choice: A process that compares [...]]]></description>
			<content:encoded><![CDATA[<p>It occurred to me that many people likely do not understand all of the terminology of travel demand models.  Because of this, I felt the need to list many of them here. <span id="more-174"></span><strong>Assignment: </strong>A process that determines the specific route of travel from one zone to another.</p>
<p><strong>Binomial Logit Mode Choice:</strong> A process that compares the utility of two travel mode choices and determines the probability of using each mode.</p>
<p><strong>BPR Equation:</strong> An equation used to determine the speed on a network link based on the ratio of the volume to the capacity.</p>
<p><strong>Centroid:</strong> A point that is linked to a TAZ that loads traffic onto the network</p>
<p><strong>Centroid Connector:</strong> The link that connects a centroid to the rest of the network.</p>
<p><strong>Equilibrium Assignment:</strong> An assignment method that iteratively assigns and reassigns traffic based on revised travel times on each link.</p>
<p><strong>Friction Factors:</strong> Factors that are used in distribution to refine the distance measure between zones.</p>
<p><strong>The Four Step Process:</strong> A process of modeling that began in the 1950s that performs four major steps: trip generation, trip distribution, mode choice, and assignment.</p>
<p><strong>Fratar Model:</strong> An iterative gravity model used to determine trip interchanges where total productions and attractions are known, but not necessarily balanced.</p>
<p><strong>Gravity Model Distribution:</strong> A process to determine the likelihood of traveling from one zone to another based on the attractiveness of the destination compared to the distance from the origin to the destination.</p>
<p><strong>Link:</strong> A piece of roadway in the network</p>
<p><strong>Mode Choice: </strong>A process that determines the economic utility of all available forms of travel from one zone to another and splits trips (from the trip distribution step) into a variety of modes (depending on those that exist).</p>
<p><strong>Multinomial Logit Mode Choice: </strong>A process that compares the utility of multiple travel mode choices where each is a separate and distinct choice.</p>
<p><strong>Nested Logit Mode Choice:</strong> A process that compares the utility of multiple travel mode choices as a string of choices and sub-choices.  An example would be a structure illustrated below (click on the image for a larger view).</p>
<dl id="attachment_175" class="wp-caption alignnone" style="width: 160px;">
<dt class="wp-caption-dt"><a href="http://www.siliconcreek.net/wordpress/wp-content/uploads/2008/08/nestedlogit.jpg" rel="shadowbox[sbpost-174];player=img;" title="Nested Logit Diagram"><img class="size-thumbnail wp-image-175" title="Nested Logit Diagram" src="http://www.siliconcreek.net/wordpress/wp-content/uploads/2008/08/nestedlogit-150x150.jpg" alt="This is a diagram of nested logit mode choice." width="150" height="150" /></a></dt>
</dl>
<p><strong>Network:</strong> A collection of links, nodes, centroids, etc. that simulate the major travel facilities in the model area.</p>
<p><strong>Traffic Analysis Zone (AKA: zone, TAZ):</strong> A geographic division, much like a census block, that defines an area of homes and businesses used in the travel demand model.</p>
<p><strong>Trip Generation: </strong>A process of counting the homes, employees (usually by type), schools, and other activities that generate traffic to and from them.  Trips are generated as attractions and productions.</p>
<p><strong>Trip Distribution:</strong> A process of determine where generated trip productions are linked to generated trip attractions.  This determines the number of people that will go from one zone to another.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.siliconcreek.net/transportation/travel-demand-modeling-101-part-1-terminology/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to the Four Step Travel Demand Model</title>
		<link>http://www.siliconcreek.net/transportation/introduction-to-the-four-step-travel-demand-model</link>
		<comments>http://www.siliconcreek.net/transportation/introduction-to-the-four-step-travel-demand-model#comments</comments>
		<pubDate>Tue, 27 May 2008 06:00:32 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Transportation]]></category>
		<category><![CDATA[four step model]]></category>

		<guid isPermaLink="false">http://www.siliconcreek.net/?p=170</guid>
		<description><![CDATA[The center of most travel demand models is the &#8220;Four Step Model&#8221;.  This model was created in the 1950s to determine the demand on roadways.  The four steps include: Trip Generation Trip Distribution Mode Choice Trip Assignment The first step in the process, Trip Generation, uses socioeconomic data to determine the number of trips produced [...]]]></description>
			<content:encoded><![CDATA[<p>The center of most travel demand models is the &#8220;Four Step Model&#8221;.  This model was created in the 1950s to determine the demand on roadways.  The four steps include:</p>
<ol>
<li>Trip Generation</li>
<li>Trip Distribution</li>
<li>Mode Choice</li>
<li>Trip Assignment</li>
</ol>
<p><span id="more-170"></span></p>
<p>The first step in the process, Trip Generation, uses socioeconomic data to determine the number of trips produced by a traffic analysis zone (or census tract, census blockgroup, or other geographic division).  The socioeconomic data normally includes population, auto ownership, and employment information at the very least.</p>
<p>The second step is trip distribution.  Once the number of trips are known, trip distribution determines where the trips will go.  This normally uses a gravity model, which will be discussed in a future post.  This step takes in several factors, including the number of trip productions, the number of trip attractions, and an impedance value.  The impedance value is the resistance to travel, which could include distance, time, tolls, or a combination of those.  Each model is different in this regard.</p>
<p>The third step is mode choice.  This step determines what vehicle trips will utilize when going from one zone to another.  This step can be particularly complex or extremely simple, depending on the area included in the model.  Some models have very simple mode choice steps because transit isn&#8217;t available, or it doesn&#8217;t have a significant effect.  Other models can be extremely complex, such as a model for Chicago or New York, which would include autos, bus transit, subway transit, urban rail (such as Chicago&#8217;s Metra Rail), and intercity rail transit (such as the Amtrak service that connects New York to Boston, Baltimore, and Washington, DC).</p>
<p>The final step is trip assignment.  This step takes all of the trips from mode choice (which it now knows if they are trips that will drive alone, share a ride, use the bus, or use another mode of transportation) and assigns them to a transportation network.  Prior to the mid-1980s, these networks were largely text based, but with the advent of Geographic Information Systems and personal computers in the mid-1980s and moving forward, these networks became graphical.</p>
<p>These four steps represent the basic building blocks of most transportation models.  These steps are a basic way to ask:</p>
<ul>
<li> How many people are going to travel?</li>
<li>Where are they going to go?</li>
<li>What transportation mode are they going to use to get there?</li>
<li>What route will they take to get there?</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.siliconcreek.net/transportation/introduction-to-the-four-step-travel-demand-model/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
