<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ascend4.org/index.php?action=history&amp;feed=atom&amp;title=Automatic_recursive_initialisation</id>
	<title>Automatic recursive initialisation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ascend4.org/index.php?action=history&amp;feed=atom&amp;title=Automatic_recursive_initialisation"/>
	<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;action=history"/>
	<updated>2026-05-03T18:45:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1100&amp;oldid=prev</id>
		<title>Jpye at 04:40, 2 August 2010</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1100&amp;oldid=prev"/>
		<updated>2010-08-02T04:40:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:40, 2 August 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This functionality is due for release in version 0.9.8.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This functionality is due for release in version 0.9.8.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This &lt;/del&gt;is some new code that deals with setting default values so that models can be returned to their as-loaded state correctly. The implementation starts with the default definition of &amp;lt;tt&amp;gt;METHOD on_load&amp;lt;/tt&amp;gt; from {{src|models/basemodel.a4l}}:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In ASCEND we write [[default_self]] [[METHOD]]s to set any initial &#039;guess&#039; values for variables that might otherwise not converge properly, or converge to an undesired value. Up to now, it was up to the user to ensure that all the nested sub-models in their model were correctly initialised, through the correct chaining-together of [[RUN]] statements.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Now there &lt;/ins&gt;is some new code that deals with setting default values so that models can be returned to their as-loaded state correctly. The implementation starts with the default definition of &amp;lt;tt&amp;gt;METHOD on_load&amp;lt;/tt&amp;gt; from {{src|models/basemodel.a4l}}:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=a4c&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=a4c&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jpye</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1099&amp;oldid=prev</id>
		<title>Jpye at 04:38, 2 August 2010</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1099&amp;oldid=prev"/>
		<updated>2010-08-02T04:38:55Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:38, 2 August 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l30&quot;&gt;Line 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 30:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The [[EXTERNAL]] code is actually the built-in code from {{src|ascend/packages/defaultall.c}}. The first function, &amp;lt;tt&amp;gt;defaultself_visit_childatoms&amp;lt;/tt&amp;gt; returns the values of all locally-defined atoms to their &amp;#039;default&amp;#039; value, as taken from the variable&amp;#039;s type declaration ([[ATOM]] statement, for example see {{src|models/atoms.a4l}}. The second function, &amp;lt;tt&amp;gt;defaultself_visit_submodels&amp;lt;/tt&amp;gt; runs the &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; on any sub-models of the top level model (and this then operates recursively down all the levels). Finally, the &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is run, which by default does nothing. It is intended that, using this approach, the user can just write a &amp;lt;tt&amp;gt;METHOD default&amp;lt;/tt&amp;gt; if there is anything in the model that needs to be initialised to anything other than its default value.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The [[EXTERNAL]] code is actually the built-in code from {{src|ascend/packages/defaultall.c}}. The first function, &amp;lt;tt&amp;gt;defaultself_visit_childatoms&amp;lt;/tt&amp;gt; returns the values of all locally-defined atoms to their &amp;#039;default&amp;#039; value, as taken from the variable&amp;#039;s type declaration ([[ATOM]] statement, for example see {{src|models/atoms.a4l}}. The second function, &amp;lt;tt&amp;gt;defaultself_visit_submodels&amp;lt;/tt&amp;gt; runs the &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; on any sub-models of the top level model (and this then operates recursively down all the levels). Finally, the &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is run, which by default does nothing. It is intended that, using this approach, the user can just write a &amp;lt;tt&amp;gt;METHOD default&amp;lt;/tt&amp;gt; if there is anything in the model that needs to be initialised to anything other than its default value.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Using the above system, a composite model can be declared by assembling sub-models, and there is no need to manually declare any initialisation code for the top-level model; it will be defined automatically as above. This &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;is &lt;/del&gt;especially useful in the case of [[canvas-based &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;modelling with &lt;/del&gt;ASCEND]], where the user expects this default behaviour to &#039;just happen&#039;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Using the above system, a composite model can be declared by assembling sub-models, and there is no need to manually declare any initialisation code for the top-level model; it will be defined automatically as above. This &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;should be &lt;/ins&gt;especially useful in the case of &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the &lt;/ins&gt;[[canvas-based &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;modeller for &lt;/ins&gt;ASCEND]], where the user expects this default behaviour to &#039;just happen&#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A problem with the above approach is that it mixes up the neatly divided &amp;lt;tt&amp;gt;specify&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;values&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; earlier recommended. We are still working out how best to resolve that.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A problem with the above approach is that it mixes up the neatly divided &amp;lt;tt&amp;gt;specify&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;values&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; earlier recommended. We are still working out how best to resolve that.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jpye</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1098&amp;oldid=prev</id>
		<title>Jpye at 04:37, 2 August 2010</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1098&amp;oldid=prev"/>
		<updated>2010-08-02T04:37:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:37, 2 August 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l33&quot;&gt;Line 33:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A problem with the above approach is that it mixes up the neatly divided &amp;lt;tt&amp;gt;specify&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;values&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; earlier recommended. We are still working out how best to resolve that.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A problem with the above approach is that it mixes up the neatly divided &amp;lt;tt&amp;gt;specify&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;values&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; earlier recommended. We are still working out how best to resolve that.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Some sample models showing this functionality are given in {{srcdir|models/test/defaultall}}.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Documentation]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Documentation]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Development]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Development]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jpye</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1097&amp;oldid=prev</id>
		<title>Jpye: Created page with &#039;{{experimental}}  This functionality is due for release in version 0.9.8.  This is some new code that deals with setting default values so that models can be returned to their as…&#039;</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Automatic_recursive_initialisation&amp;diff=1097&amp;oldid=prev"/>
		<updated>2010-08-02T04:35:54Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;{{experimental}}  This functionality is due for release in version 0.9.8.  This is some new code that deals with setting default values so that models can be returned to their as…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{experimental}}&lt;br /&gt;
&lt;br /&gt;
This functionality is due for release in version 0.9.8.&lt;br /&gt;
&lt;br /&gt;
This is some new code that deals with setting default values so that models can be returned to their as-loaded state correctly. The implementation starts with the default definition of &amp;lt;tt&amp;gt;METHOD on_load&amp;lt;/tt&amp;gt; from {{src|models/basemodel.a4l}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
METHOD on_load;&lt;br /&gt;
  RUN default_self;&lt;br /&gt;
END on_load;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This in turn is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
METHOD default_self;&lt;br /&gt;
  EXTERNAL defaultself_visit_childatoms(SELF);&lt;br /&gt;
  EXTERNAL defaultself_visit_submodels(SELF); (* overwrite ATOM defaults explicit nested code if needed *)&lt;br /&gt;
  RUN default; (* local overrides *)&lt;br /&gt;
END default_self;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
METHOD default;&lt;br /&gt;
  (* do nothing, user can over-write this *)&lt;br /&gt;
END default;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[EXTERNAL]] code is actually the built-in code from {{src|ascend/packages/defaultall.c}}. The first function, &amp;lt;tt&amp;gt;defaultself_visit_childatoms&amp;lt;/tt&amp;gt; returns the values of all locally-defined atoms to their &amp;#039;default&amp;#039; value, as taken from the variable&amp;#039;s type declaration ([[ATOM]] statement, for example see {{src|models/atoms.a4l}}. The second function, &amp;lt;tt&amp;gt;defaultself_visit_submodels&amp;lt;/tt&amp;gt; runs the &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; on any sub-models of the top level model (and this then operates recursively down all the levels). Finally, the &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; is run, which by default does nothing. It is intended that, using this approach, the user can just write a &amp;lt;tt&amp;gt;METHOD default&amp;lt;/tt&amp;gt; if there is anything in the model that needs to be initialised to anything other than its default value.&lt;br /&gt;
&lt;br /&gt;
Using the above system, a composite model can be declared by assembling sub-models, and there is no need to manually declare any initialisation code for the top-level model; it will be defined automatically as above. This is especially useful in the case of [[canvas-based modelling with ASCEND]], where the user expects this default behaviour to &amp;#039;just happen&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
A problem with the above approach is that it mixes up the neatly divided &amp;lt;tt&amp;gt;specify&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;values&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;default_self&amp;lt;/tt&amp;gt; earlier recommended. We are still working out how best to resolve that.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Jpye</name></author>
	</entry>
</feed>