<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://emk.energylink.co.nz/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=WoodsM</id>
	<title>EMK Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://emk.energylink.co.nz/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=WoodsM"/>
	<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/Special:Contributions/WoodsM"/>
	<updated>2026-04-29T18:18:56Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.8</generator>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5729</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5729"/>
		<updated>2019-07-04T04:04:16Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Reports|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''Output Spec Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || Output Spec Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Defines a Prefilter that restricts the results being used to generate the report. (''described below'')&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Prefilter===&lt;br /&gt;
There are two types of prefilter available: a date range prefilter, and version prefilters.  You can run more than one prefilter by separating each specification with a semi-colon.&lt;br /&gt;
&lt;br /&gt;
'''Date Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Date:&amp;lt;date from&amp;gt;-&amp;lt;date to&amp;gt; (dates in d MMM yyyy format)&lt;br /&gt;
&lt;br /&gt;
E.g. Date:1 Mar 2030 - 1 Mar 2035&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to the date range given&lt;br /&gt;
&lt;br /&gt;
'''Version Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Version:&amp;lt;volatility variable name&amp;gt;=&amp;lt;values list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
E.g. Version:InflowYear=1947,1980,2005-2010&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to versions where the volatility value is in the list of values given.  The list of values are specified in the same way as they are in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''.&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Year(&amp;lt;MMM&amp;gt;) - A division for each year in the forecast, where the year is deemed to start at the given month.  For example: 'Year(Apr):All'  will create divisions based on 1 Aoril - 31 March years&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5728</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5728"/>
		<updated>2019-07-04T04:03:55Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Reports|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''Output Spec Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || Output Spec Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Defines a Prefilter that restricts the results being used to generate the report. (''described below'')&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Prefilter===&lt;br /&gt;
There are two types of prefilter available: a date range prefilter, and version prefilters.  You can run more than one prefilter by separating each specification with a semi-colon.&lt;br /&gt;
&lt;br /&gt;
'''Date Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Date:&amp;lt;date from&amp;gt;-&amp;lt;date to&amp;gt; (dates in d MMM yyyy format)&lt;br /&gt;
&lt;br /&gt;
E.g. Date:1 Mar 2030 - 1 Mar 2035&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to the date range given&lt;br /&gt;
&lt;br /&gt;
'''Version Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Version:&amp;lt;volatility variable name&amp;gt;=&amp;lt;values list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
E.g. Version:InflowYear=1947,1980,2005-2010&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to versions where the volatility value is in the list of values given.  The list of values are specified in the same way as they are in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''.&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Year(MMM) - A division for each year in the forecast, where the year is deemed to start at the given month.  For example: 'Year(Apr):All'  will create divisions based on 1 Aoril - 31 March years&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5727</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5727"/>
		<updated>2019-07-02T23:42:59Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Prefilter */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Reports|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''Output Spec Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || Output Spec Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Defines a Prefilter that restricts the results being used to generate the report. (''described below'')&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Prefilter===&lt;br /&gt;
There are two types of prefilter available: a date range prefilter, and version prefilters.  You can run more than one prefilter by separating each specification with a semi-colon.&lt;br /&gt;
&lt;br /&gt;
'''Date Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Date:&amp;lt;date from&amp;gt;-&amp;lt;date to&amp;gt; (dates in d MMM yyyy format)&lt;br /&gt;
&lt;br /&gt;
E.g. Date:1 Mar 2030 - 1 Mar 2035&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to the date range given&lt;br /&gt;
&lt;br /&gt;
'''Version Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Version:&amp;lt;volatility variable name&amp;gt;=&amp;lt;values list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
E.g. Version:InflowYear=1947,1980,2005-2010&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to versions where the volatility value is in the list of values given.  The list of values are specified in the same way as they are in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''.&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5726</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5726"/>
		<updated>2019-07-02T23:40:03Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* The Output Specs Details Box */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Reports|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''Output Spec Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || Output Spec Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Defines a Prefilter that restricts the results being used to generate the report. (''described below'')&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Prefilter===&lt;br /&gt;
There are two types of prefilter available: a date range prefilter, and version prefilters.  You can run more than one prefilter by separating each specification with a semi-colon.&lt;br /&gt;
&lt;br /&gt;
'''Date Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Date:&amp;lt;date from&amp;gt;-&amp;lt;date to&amp;gt; (dates in d MMM yyyy format)&lt;br /&gt;
&lt;br /&gt;
E.g. Date:1 Mar 2030 - 1 Mar 2035&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to the date range given&lt;br /&gt;
&lt;br /&gt;
'''Version Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Version:&amp;lt;volatility variable name&amp;gt;=&amp;lt;values list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
E.g. Version:InflowYear=1947,1980,2005-2010&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to versions where the volatility value is in the list of values given.  The list of values are specified in the same way as they are in the volatility matrix.&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5725</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5725"/>
		<updated>2019-07-02T23:39:41Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Prefilter */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Reports|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''Output Spec Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || Output Spec Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Defines a Prefilter that restricts the results being used to generate the report. (''described below'')&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Prefilter===&lt;br /&gt;
There are two types of prefilter available: a date range prefilter, and version prefilters.  You can run more than one prefilter by separating each specification with a semi-colon.&lt;br /&gt;
&lt;br /&gt;
'''Date Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Date:&amp;lt;date from&amp;gt;-&amp;lt;date to&amp;gt; (dates in d MMM yyyy format)&lt;br /&gt;
&lt;br /&gt;
E.g. Date:1 Mar 2030 - 1 Mar 2035&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to the date range given&lt;br /&gt;
&lt;br /&gt;
'''Version Prefilter'''&lt;br /&gt;
&lt;br /&gt;
Format: Version:&amp;lt;volatility variable name&amp;gt;=&amp;lt;values list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
E.g. Version:InflowYear=1947,1980,2005-2010&lt;br /&gt;
&lt;br /&gt;
This restricts the data being processed to versions where the volatility value is in the list of values given.  The list of values are specified in the same way as they are in the volatility matrix.&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5724</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=5724"/>
		<updated>2019-07-02T23:38:31Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* The Output Specs Details Box */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Reports|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''Output Spec Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || Output Spec Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Defines a Prefilter that restricts the results being used to generate the report. (''described below'')&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Prefilter===&lt;br /&gt;
There are two types of prefilter available: a date range prefilter, and version prefilters.  You can run more than one prefilter by separating each specification with a semi-colon.&lt;br /&gt;
'''Date Prefilter'''&lt;br /&gt;
Format: Date:&amp;lt;date from&amp;gt;-&amp;lt;date to&amp;gt; (dates in d MMM yyyy format)&lt;br /&gt;
E.g. Date:1 Mar 2030 - 1 Mar 2035&lt;br /&gt;
This restricts the data being processed to the date range given&lt;br /&gt;
'''Version Prefilter'''&lt;br /&gt;
Format: Version:&amp;lt;volatility variable name&amp;gt;=&amp;lt;values list&amp;gt;&lt;br /&gt;
E.g. Version:InflowYear=1947,1980,2005-2010&lt;br /&gt;
This restricts the data being processed to versions where the volatility value is in the list of values given.  The list of values are specified in the same way as they are in the volatility matrix. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=Main_Page&amp;diff=5723</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=Main_Page&amp;diff=5723"/>
		<updated>2017-09-11T22:28:05Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
; Current Release Version of EMarket: ''EMarket 5.4.1''&lt;br /&gt;
&lt;br /&gt;
''[[EMK:EMarket 5 Release Notes|EMarket 5 Release Notes]]''&lt;br /&gt;
&lt;br /&gt;
'''[[EMK:EMarket User Manual | EMarket User Manual]]'''&lt;br /&gt;
&lt;br /&gt;
'''[[EMK:EMarket 5 Notes | EMarket 5 Release Commentary]]'''&lt;br /&gt;
&lt;br /&gt;
'''[[EMK:EMarket Development | EMarket Development Path and Requests]]'''&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=Main_Page&amp;diff=5720</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=Main_Page&amp;diff=5720"/>
		<updated>2017-09-11T20:52:22Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
; Current Release Version of EMarket: ''EMarket 5.4.1''&lt;br /&gt;
&lt;br /&gt;
''[[EMK:EMarket 5 Release Notes|EMarket 5 Release Notes]]''&lt;br /&gt;
&lt;br /&gt;
'''[[EMK:EMarket User Manual | EMarket User Manual]]'''&lt;br /&gt;
&lt;br /&gt;
'''[[EMK:EMarket 5 Notes | EMarket 5 Release Commentary]]'''&lt;br /&gt;
&lt;br /&gt;
'''[[EMK:EMarket Development | EMarket Development Path and Requests]]'''&lt;br /&gt;
&lt;br /&gt;
'''[[EEX:Energy Exchange| Energy Exchange Documentation]]'''&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Water_Values_Bulletins&amp;diff=5719</id>
		<title>EMK:Water Values Bulletins</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Water_Values_Bulletins&amp;diff=5719"/>
		<updated>2016-02-28T21:13:33Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
&lt;br /&gt;
On water values in EMarket versions 5 and 6:&lt;br /&gt;
&lt;br /&gt;
[[EMK:Multi Dimensional Water Values | Multi Dimensional Water Values]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On water values EMarket versions 4 and earlier:&lt;br /&gt;
&lt;br /&gt;
[[EMK:Water Values and Hydro Offers | Water Values and Hydro Offers]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Water Values in the EMarket Model | Water Values in the EMarket Model]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Improvements to Water Values | Improvements to Water Values (2009)]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Technical Bulletins | Back to Technical Bulletins]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Water_Values_Bulletins&amp;diff=5718</id>
		<title>EMK:Water Values Bulletins</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Water_Values_Bulletins&amp;diff=5718"/>
		<updated>2016-02-28T21:06:17Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
&lt;br /&gt;
 This bulletin currently relates to water values in EMarket 4.  It is due to be updated to EMarket 5.&lt;br /&gt;
&lt;br /&gt;
On water values in EMarket versions 5 and 6:&lt;br /&gt;
&lt;br /&gt;
[[EMK:Multi Dimensional Water Values | Multi Dimensional Water Values]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On water values EMarket versions 4 and earlier:&lt;br /&gt;
&lt;br /&gt;
[[EMK:Water Values and Hydro Offers | Water Values and Hydro Offers]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Water Values in the EMarket Model | Water Values in the EMarket Model]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Improvements to Water Values | Improvements to Water Values (2009)]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Technical Bulletins | Back to Technical Bulletins]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4641</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4641"/>
		<updated>2013-09-10T21:15:23Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Array Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Array Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's array functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Sum(Node.Price)&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Integer or Real Array, [Exclude Value] || Real || Max(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Integer or Real Array, [Exclude Value] || Real || Min(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Integer or Real Array, [Exclude Value] || Real || StdDev(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Avg(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || 2 x Integer or Real Array, (Values, Weights) || Real || WgtAvg(Generator.Generation,Generator.Cost)&lt;br /&gt;
|-&lt;br /&gt;
| ArrMult || Returns an array whose elements are the product of the elements in an array and a scalar value || Integer or Real Array, Integer or Real Value || Real Array || ArrMult(Node.Demand, Duration)&lt;br /&gt;
|-&lt;br /&gt;
| AddElements || Returns an array whose elements are the sum of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Array || AddElements(Node.Demand, Node.Losses)&lt;br /&gt;
|-&lt;br /&gt;
| SubElements || Returns an array whose elements are the difference of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Array || SubElements(Circuit.Flow, Circuit.Losses)&lt;br /&gt;
|-&lt;br /&gt;
| MultiplyElements || Returns an array whose elements are the product of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Array || MultiplyElements(Node.Demand, Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4640</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4640"/>
		<updated>2013-09-10T21:12:32Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Array Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Array Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's array functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Sum(Node.Price)&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Integer or Real Array, [Exclude Value] || Real || Max(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Integer or Real Array, [Exclude Value] || Real || Min(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Integer or Real Array, [Exclude Value] || Real || StdDev(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Avg(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || 2 x Integer or Real Array, (Values, Weights) || Real || WgtAvg(Generator.Generation,Generator.Cost)&lt;br /&gt;
|-&lt;br /&gt;
| ArrMult || Returns an array whose elements are the product of the elements in an array and a scalar value || Integer or Real Array, Integer or Real Value || Real Value Array || ArrMult(Node.Demand, Duration)&lt;br /&gt;
|-&lt;br /&gt;
| AddElements || Returns an array whose elements are the sum of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || AddElements(Node.Demand, Node.Losses)&lt;br /&gt;
|-&lt;br /&gt;
| SubElements || Returns an array whose elements are the difference of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || SubElements(Circuit.Flow, Circuit.Losses)&lt;br /&gt;
|-&lt;br /&gt;
| MultiplyElements || Returns an array whose elements are the product of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || MultiplyElements(Node.Demand, Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4639</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4639"/>
		<updated>2013-09-10T21:11:26Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Array Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Array Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's array functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Sum(Node.Price)&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Integer or Real Array, [Exclude Value] || Real || Max(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Integer or Real Array, [Exclude Value] || Real || Min(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Integer or Real Array, [Exclude Value] || Real || StdDev(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Avg(Generator.Generation)&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || 2 x Integer or Real Array, (Values, Weights) || Real || WgtAvg(Generator.Generation,Generator.Cost)&lt;br /&gt;
|-&lt;br /&gt;
| ArrMult || Creates a new array, whose elements are the product of the elements in an array and a scalar value || Integer or Real Array, Integer or Real Value || Real Value Array || ArrMult(Node.Demand, Duration)&lt;br /&gt;
|-&lt;br /&gt;
| AddElements || Creates a new array, whose elements are the sum of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || AddElements(Node.Demand, Node.Losses)&lt;br /&gt;
|-&lt;br /&gt;
| SubElements || Creates a new array, whose elements are the difference of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || SubElements(Circuit.Flow, Circuit.Losses)&lt;br /&gt;
|-&lt;br /&gt;
| MultiplyElements || Creates a new array, whose elements are the product of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || MultiplyElements(Node.Demand, Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4638</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4638"/>
		<updated>2013-09-10T21:10:31Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Array Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Array Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's array functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Integer or Real Array, [Exclude Value] || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Integer or Real Array, [Exclude Value] || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Integer or Real Array, [Exclude Value] || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || 2 x Integer or Real Array, (Values, Weights) || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| ArrMult || Creates a new array, whose elements are the product of the elements in an array and a scalar value || Integer or Real Array, Integer or Real Value || Real Value Array || ArrMult(Node.Demand, Duration) ||&lt;br /&gt;
|-&lt;br /&gt;
| AddElements || Creates a new array, whose elements are the sum of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || AddElements(Node.Demand, Node.Losses) ||&lt;br /&gt;
|-&lt;br /&gt;
| SubElements || Creates a new array, whose elements are the difference of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || SubElements(Circuit.Flow, Circuit.Losses) ||&lt;br /&gt;
|-&lt;br /&gt;
| MultiplyElements || Creates a new array, whose elements are the product of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || MultiplyElements(Node.Demand, Node.Price) ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4637</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4637"/>
		<updated>2013-09-10T21:10:09Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Array Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Array Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's array functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Integer or Real Array, [Exclude Value] || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Integer or Real Array, [Exclude Value] || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Integer or Real Array, [Exclude Value] || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || 2 x Integer or Real Array, (Values, Weights) || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| ArrMult || Creates a new array, whose elements are the product of the elements in an array and a scalar value || Integer or Real Array, Integer or Real Value || Real Value Array || ArrMult(Node.Demand, Duration) ||&lt;br /&gt;
|-&lt;br /&gt;
| AddElements || Creates a new array, whose elements are the sum of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || AddElements(Node.Demand, Node.Losses) ||&lt;br /&gt;
|-&lt;br /&gt;
| SubElements || Creates a new array, whose elements are the difference of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || SubElements(Circuit.Flow, Circuit.Losses) ||&lt;br /&gt;
|-&lt;br /&gt;
| MultiplyElements || Creates a new array, whose elements are the product of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || MultiplyElements(Node.Demand, Node.Price) ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4636</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4636"/>
		<updated>2013-09-10T21:05:13Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Arithmetic Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Array Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's array functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
| Sum || Total value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Integer or Real Array, [Exclude Value] || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Integer or Real Array, [Exclude Value] || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Integer or Real Array, [Exclude Value] || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Integer or Real Array, [Exclude Value] || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || 2 x Integer or Real Array, (Values, Weights) || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| ArrMult || Creates a new array, whose elements are the product of the elements in an array and a scalar value || Integer or Real Array, Integer or Real Value || Real Value Array || ArrMult(Node.Demand, Duration) ||&lt;br /&gt;
| AddElements || Creates a new array, whose elements are the sum of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || AddElements(Node.Demand, Node.Losses) ||&lt;br /&gt;
| SubElements || Creates a new array, whose elements are the difference of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || SubElements(Circuit.Flow, Circuit.Losses) ||&lt;br /&gt;
| MultiplyElements || Creates a new array, whose elements are the product of the elements in two arrays (the arrays must be of the same size) || 2 x Integer or Real Arrays || Real Value Array || MultiplyElements(Node.Demand, Node.Price) ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4635</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4635"/>
		<updated>2013-09-10T20:42:54Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Arithmetic Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Integer or Real Array, (Exclude Value) || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4634</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4634"/>
		<updated>2013-08-20T22:20:31Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Reports|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4633</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4633"/>
		<updated>2013-08-20T22:19:47Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports to be generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. OS reports can be run as part of a '''''[[EMK:Report Batch|Report Batch]]''''' and automatically generated on the completion of the run, or they may be generated at any time from run results. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4632</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4632"/>
		<updated>2013-08-20T21:19:11Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output Specification (OS) Resource allows you to define customised reports in a tabular form which are generated from run output data. Reports generated using OS Resources are text based in a comma separated (CSV) form and the resulting files can be opened in Excel or a number of other editors. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4631</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4631"/>
		<updated>2013-08-20T21:02:03Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''': this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4630</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4630"/>
		<updated>2013-08-20T21:01:49Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample. '''Warning''' this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4629</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4629"/>
		<updated>2013-08-20T21:01:12Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample '''''Warning''''' this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4628</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4628"/>
		<updated>2013-08-20T21:00:19Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample '''WARNING''' this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4627</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4627"/>
		<updated>2013-08-20T20:57:01Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
*Count() - The number of values in a sample.&lt;br /&gt;
*Percentile.&amp;lt;n&amp;gt;() - The nth percentile of values in the sample #Warning# this function may use a lot of memory and should be used with care, especially for large forecasts.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4626</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4626"/>
		<updated>2013-08-20T05:08:07Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Partition:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Partitions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4625</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4625"/>
		<updated>2013-08-20T05:07:30Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;date/time division&amp;gt;:All (except for 'Date' partition) || Week:All&lt;br /&gt;
|}&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4624</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4624"/>
		<updated>2013-08-20T05:06:14Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;Entity Type&amp;gt;:&amp;lt;All or List&amp;gt; || Generator:Huntly, Waikato&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4623</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4623"/>
		<updated>2013-08-20T05:04:44Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4622</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4622"/>
		<updated>2013-08-20T05:04:10Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| Function:&amp;lt;list of output spec functions&amp;gt; || Function:Ave(Generator.Generation), Max(Node.Price)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Syntax''' || '''Example''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| Version:All, Version(&amp;lt;volatility matrix variable&amp;gt;):All || Version(InflowYear):All&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4621</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4621"/>
		<updated>2013-08-20T05:00:00Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
*''Syntax''  Function : &amp;lt;list of output spec functions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4620</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4620"/>
		<updated>2013-08-20T04:59:33Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
''Syntax''  Function : &amp;lt;list of output spec functions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4619</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4619"/>
		<updated>2013-08-20T04:59:06Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Partition'''&lt;br /&gt;
*''Syntax Function'' : &amp;lt;list of output spec functions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4618</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4618"/>
		<updated>2013-08-20T04:56:28Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. This is done by progressively dividing the data using 'Partitions'.  Each partition creates a number of divisions to which data is directed according to some criterion.  The partition is specified in two parts &amp;lt;Partition Type&amp;gt;:&amp;lt;Partition specification&amp;gt;, where the specification is generally a comma delimited list.  The results of an Output Spec report is one or more CSV style files. Partitions direct data either to separate output files or to separate columns or rows within the file (similar to the way a pivot table is displayed, or a crosstab query).&lt;br /&gt;
&lt;br /&gt;
Partition Types fall into the following categories:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose''' || '''Specification'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS. || Either 'All', or a list of entity names&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition. || One or more Output Spec functions&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''. || 'All'&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods. || 'All'&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Function Divisions'''&lt;br /&gt;
*Function:&amp;lt;list of output spec functions&amp;gt;&lt;br /&gt;
The function divesion&lt;br /&gt;
&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4617</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4617"/>
		<updated>2013-08-20T04:38:58Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. These are defined using a function description and the element that is to be reported. This columns and rows elements allow the output to be exported as a grid (similar to the way a pivot table is displayed, or a crosstab query), whereas the file element defines separate output files (useful for very long runs).&lt;br /&gt;
&lt;br /&gt;
An Output Specification Partition is a concept used in structuring the contents of a Report.  Partitions are user-defined and must be one of the following types:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS.&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition.&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''.&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Output Spec functions:'''&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Entity Divisions:'''&lt;br /&gt;
*&amp;lt;Entity Type Name&amp;gt; - partitions by the entities belonging to the named entity type.  If 'All' is specified then a division is created for every entity, alternatively a list of individual entities can be specified, e.g. 'Node:BEN,HAY,OTA' will create a division for each of the three named nodes.&lt;br /&gt;
&lt;br /&gt;
'''Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4616</id>
		<title>EMK:Output Specs</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Output_Specs&amp;diff=4616"/>
		<updated>2013-08-20T04:28:18Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Output Specification Partitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
[[File:Output_Specs_Window.jpg|300px|thumb|right|Example OutputSpec Window]]&lt;br /&gt;
An Output specification (OS) Resource allows you to define custom Reports in a tabular form using Run Output data. Reports generated using OS Resources are in text based, comma separated (csv) form. This is how results are exported for external analyses. Any element shown in the results window can be exported via the Output Spec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Output Specs window has the following components:&lt;br /&gt;
*The ''''OS Details Box:'''' Used to identify ''(Name)'' and describe ''(Description)'' the OS Resource.&lt;br /&gt;
*Two ''''Formatting Check Boxes:'''' ''Repeat Column headings'' and ''Repeat Row headings'' - which determine whether the parent column and row headings appear once per column or row (Boxes unchecked), or for every column and row of the columns they apply to (Boxes checked) respectively.&lt;br /&gt;
*The ''''OS Partition Box:'''' Specifies how the results data will be summarised and presented.&lt;br /&gt;
&lt;br /&gt;
Note: OS Reports can be produced from previously generated data from the '''''[[EMK:Results|Results Window]]''''' or '''''[[EMK:Results|Results Menu]]'''''.&lt;br /&gt;
&lt;br /&gt;
==The Output Specs Details Box==&lt;br /&gt;
&lt;br /&gt;
'''OS Details Box Fields'''&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ''Name'' || OS Resource name - used to reference the OS in other Resources.&lt;br /&gt;
|-&lt;br /&gt;
| ''Description'' || Free text field for supplementary information.'&lt;br /&gt;
|-&lt;br /&gt;
| ''Prefilters'' || Specifies a date range that the OS will only process data for - this allows the OS to be used on multiple Results sets covering disparate date ranges and only extract results for a common period. The Prefilter variable is defined in the Resource/System Definition.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Formatting Check Boxes==&lt;br /&gt;
&lt;br /&gt;
The Formatting Check Boxes are used to control the output of headers in columns and rows in the output.  If the OS Resource is used when both boxes are left unchecked, then a heading only appears once in the output.  For example a parent row heading will only appear with the first child row heading as in the table below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
|  || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Running the same OS with the 'Repeat Row Headings' box checked would produce a heading configuration as below:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 1 || Child Row Heading 3&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 1&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 2&lt;br /&gt;
|-&lt;br /&gt;
| Parent Row Heading 2 || Child Row Heading 3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Repeating the headers is useful for automatic post-processing and when viewing large output files with multiple row partitions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Output Specification Partitions==&lt;br /&gt;
[[File:Output_Specs_BEN.jpg|300px|thumb|right|Example Output Specs Window #2]]&lt;br /&gt;
To create an Output Spec, file, columns and rows need to be defined. These are defined using a function description and the element that is to be reported. This columns and rows elements allow the output to be exported as a grid (similar to the way a pivot table is displayed, or a crosstab query), whereas the file element defines separate output files (useful for very long runs).&lt;br /&gt;
&lt;br /&gt;
An Output Specification Partition is a concept used in structuring the contents of a Report.  Partitions are user-defined and must be one of the following types:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''Partitions Type''' || '''Purpose'''&lt;br /&gt;
|-&lt;br /&gt;
| ''Entity'' || Describes type of data in the results set that is to be processed with the OS.&lt;br /&gt;
|-&lt;br /&gt;
| ''Function'' || Describes the processing to be carried out on the data defined by an Entity partition.&lt;br /&gt;
|-&lt;br /&gt;
| ''Version'' || Allows Output to be broken down by versions in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]'''''.&lt;br /&gt;
|-&lt;br /&gt;
| ''Date/Time'' || Allows data to be aggregated by specified time periods.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the example to the right, the file is defined by 'Year' so and output file will be created for each calendar Year. &lt;br /&gt;
&lt;br /&gt;
The 'Column definition' is for the Average Nodal Price at the BEN and HAY Nodes by each inflow year. The :2 limits the results to two decimal places.&lt;br /&gt;
&lt;br /&gt;
The 'Row Definition' is defined as MonthOfYear/Version:All which will display Average monthly Price for each inflow year &lt;br /&gt;
&lt;br /&gt;
As a result, the final output will be a file for each calendar year, and the '''Average monthly price at Benmore and Haywards for each inflow year.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Output Spec functions:'''&lt;br /&gt;
*Ave() - Average value, weighted by time.&lt;br /&gt;
*Tot() - Total value, summed by hour.&lt;br /&gt;
*Max() - Maximum value in a sample.&lt;br /&gt;
*Min() - Minimum value in a sample.&lt;br /&gt;
*First() - The first (earliest) value in a sample.&lt;br /&gt;
*Last() - The last (latest) value in a sample.&lt;br /&gt;
&lt;br /&gt;
The First and Last functions would typically be used to get the earliest and latest (in modelled time) value in a sample.  These functions do not have as much meaning if there are multiple records for each time period, i.e. if the Version or the Entity partition is not applied.  For example if you were to use the Last(Generator.Generation) function over all generators then only the latest generation for the last generator (alphabetically) would be returned.&lt;br /&gt;
&lt;br /&gt;
'''Volatility Matrix Divisions:'''&lt;br /&gt;
*Version - partitions all the simulation versions.&lt;br /&gt;
*Version(&amp;lt;volatility matrix variable&amp;gt;) - partitions the simulation versions by the given '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' variable.&lt;br /&gt;
&lt;br /&gt;
'''Main Date/Time Divisions:'''&lt;br /&gt;
*hh - half hourly&lt;br /&gt;
*1h, 2h, 3h, 4h, 6h, 8h - one, two, three, four, six and eight hourly&lt;br /&gt;
*DN - Day Night (12pm-8am, 8am-12pm)&lt;br /&gt;
*DN6 - Day Night (12pm-6am, 6am-12pm)&lt;br /&gt;
*WO - 2 divisions: Weekday, Other day&lt;br /&gt;
*WODN - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN)&lt;br /&gt;
*WODN6 - 4 divisions: Week day, Other day, Week night, Other night (Day, Night as in DN6)&lt;br /&gt;
*DOW - 7 Divisions - day of week&lt;br /&gt;
*MonthOfYear - 12 Divisions - one for each month in the year&lt;br /&gt;
*Day - A division for each day in the forecast&lt;br /&gt;
*Week - A division for each week in the forecast&lt;br /&gt;
*Month - A division for each month in the forecast&lt;br /&gt;
*Year - A division for each year in the forecast&lt;br /&gt;
*Date - A division by user entered dates.  For example 'Date:1 Apr 2015, 1 Nov 2015, 1 Jan 2016' will create four divisions separated by the three dates specified&lt;br /&gt;
&lt;br /&gt;
==Using The Output Specification Window==&lt;br /&gt;
&lt;br /&gt;
'''To create a new OS''' open Output Specs by clicking on the ''OutputSpec'' tab at the bottom left of the main page. Press ''&amp;lt;insert&amp;gt;'' to open a clean OS Window. Fill out the fields in the box at the top of the new window by pressing space to activate the cell and then typing the required information.&lt;br /&gt;
&lt;br /&gt;
'''To create the first Column or first Row Partition''' highlight the Column or Row Partition heading by clicking on it and then pressing ''&amp;lt;Ctrl&amp;gt;&amp;lt;Insert&amp;gt;'' to create a new blank Column or Row partition.&lt;br /&gt;
&lt;br /&gt;
'''To create subsequent Column or Row Partitions''' right click an existing Column or Row Partition and select the required item from the drop down menu: &lt;br /&gt;
*Sibling Partitions can be created with the ''Insert Before'' option. &lt;br /&gt;
*Parent Partitions can be created (making a child of the highlighted partition) with the ''Insert Parent'' option.&lt;br /&gt;
*Child Partitions can be created (making a parent of the highlighted partition) with the ''Insert Child'' option.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''To enter Partition details''' press the ''&amp;lt;space&amp;gt;'' key to activate the cell and start entering text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If EMarket cannot validate the entry the text will simply revert to what was in the division beforehand. An entry may not be validated because:&lt;br /&gt;
*incorrect syntax&lt;br /&gt;
*invalid data-type or time-type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The specifications are case sensitive, and for function names, data types and time types, name completion is provided.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:Resources | Back to Resources]]&lt;br /&gt;
&lt;br /&gt;
[[EMK:Outputs | Back to Outputs]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4615</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4615"/>
		<updated>2013-08-19T23:18:15Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Special Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | Random Functions]]''''' within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4614</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4614"/>
		<updated>2013-08-19T23:17:51Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Special Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all '''''[[#Random Functions | random functions]]'''''randomisation functions within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4613</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4613"/>
		<updated>2013-08-19T23:17:04Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Special Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Window | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all randomisation functions within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4612</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4612"/>
		<updated>2013-08-19T23:16:19Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Special Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the '''''[[EMK:Run Resource | Run Resource]]'''''.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all randomisation functions within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4611</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4611"/>
		<updated>2013-08-19T23:15:41Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Special Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the Run Resource.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all randomisation functions within the run&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4610</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4610"/>
		<updated>2013-08-19T23:15:31Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Special Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| RandomSeed || This variable is set up according to the 'Random Seed' option in the Run Resource.  It allows the generation of random sequences to be&lt;br /&gt;
coordinated for all randomisation functions within the run.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4609</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4609"/>
		<updated>2013-08-19T23:12:05Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Random Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
The following functions create a random sequence, the results of which depends on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4608</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4608"/>
		<updated>2013-08-19T23:11:05Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Special Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
===Special Variables===&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
the following random functions create a random sequence, the results of which depend on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4607</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4607"/>
		<updated>2013-08-19T23:10:06Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*'''''[[#Constants | Constants]]'''''&lt;br /&gt;
*'''''[[#Variables | Variables]]'''''&lt;br /&gt;
*'''''[[#Operators | Operators]]'''''&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
==Special Variables==&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
the following random functions create a random sequence, the results of which depend on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4606</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4606"/>
		<updated>2013-08-19T23:09:10Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*Constants&lt;br /&gt;
*Variables&lt;br /&gt;
*Operators&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''[[#Functions | Functions]]'''''&lt;br /&gt;
&lt;br /&gt;
==Constants==&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
==Special Variables==&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
the following random functions create a random sequence, the results of which depend on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4605</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4605"/>
		<updated>2013-08-19T23:07:20Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Other Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*Constants&lt;br /&gt;
*Variables&lt;br /&gt;
*Operators&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''Functions'''''&lt;br /&gt;
&lt;br /&gt;
'''Constants'''&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
'''Variables'''&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
==Special Variables==&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the value being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
the following random functions create a random sequence, the results of which depend on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4604</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4604"/>
		<updated>2013-08-19T23:06:37Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Other Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*Constants&lt;br /&gt;
*Variables&lt;br /&gt;
*Operators&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''Functions'''''&lt;br /&gt;
&lt;br /&gt;
'''Constants'''&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
'''Variables'''&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
==Special Variables==&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the v being averaged.  M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the half-life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer)  || Real || RunningAverage(DateTime, Generator:ABC.Generation, 7)&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
the following random functions create a random sequence, the results of which depend on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4603</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4603"/>
		<updated>2013-08-19T23:05:21Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: /* Other Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*Constants&lt;br /&gt;
*Variables&lt;br /&gt;
*Operators&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''Functions'''''&lt;br /&gt;
&lt;br /&gt;
'''Constants'''&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
'''Variables'''&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
==Special Variables==&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| RunningAverage || This function facilitates the smoothing of a value over time by applying a running average to the given value. The formula used is V = MV' + (1 - M)v, where V is the running average value, V' is the last value of the running average, v is the v being averaged and M is given by the formula: M = Exp(-Ln(2) * (D / H))  where D is the duration in days of the time step and H is the Half-Life parameter.  On the first step M = 0.  || The current Date/Time, input value (Real or Integer), half-life days (Real or Integer) || RunningAverage(DateTime, Generator:ABC.Generation, 7) ||&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
the following random functions create a random sequence, the results of which depend on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
	<entry>
		<id>http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4602</id>
		<title>EMK:Formulae and Functions</title>
		<link rel="alternate" type="text/html" href="http://emk.energylink.co.nz/index.php?title=EMK:Formulae_and_Functions&amp;diff=4602"/>
		<updated>2013-08-19T22:30:59Z</updated>

		<summary type="html">&lt;p&gt;WoodsM: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#hidens:}}&lt;br /&gt;
Formulae can be entered as substitutes for specific values into most fields in EMarket to control the derivation of variable values at run time. A formula can contain any combination of:&lt;br /&gt;
*Constants&lt;br /&gt;
*Variables&lt;br /&gt;
*Operators&lt;br /&gt;
*'''''[[EMK:Entity.Traits | Entities and Traits]]'''''&lt;br /&gt;
*'''''Functions'''''&lt;br /&gt;
&lt;br /&gt;
'''Constants'''&lt;br /&gt;
&lt;br /&gt;
Constants can be:&lt;br /&gt;
*''Numbers:'' Integers or Reals (e.g. 1, 2.5, -3), they can also be entered in scientific notation e.g. '3E+10'.&lt;br /&gt;
*''Strings:'' Written inside double quotes e.g. &amp;quot;A Node&amp;quot;&lt;br /&gt;
*''Dates:'' Must be enclosed in single quotes e.g '1/3/2004' or '14 April 2005' &lt;br /&gt;
&lt;br /&gt;
'''Warning:''' The format for entering dates should compatible with the computer's local date (locality) setting&lt;br /&gt;
&lt;br /&gt;
'''Variables'''&lt;br /&gt;
&lt;br /&gt;
Variables can be regarded as user-defined Entity.Traits which can be defined in the '''''[[EMK:Run Window#Volatility Matrix|Volatility Matrix]]''''' or in a '''''[[EMK:Schedules|Schedule]]'''''. Previously defined variables can be used in formulae.&lt;br /&gt;
&lt;br /&gt;
Note: EMarket provides a 'system' variable the user need not define: 'DateTime' which is of type 'Date' and gives the current simulation date as the model runs.&lt;br /&gt;
&lt;br /&gt;
==Special Variables==&lt;br /&gt;
&lt;br /&gt;
These variable names are automatically included in the schedule&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable Name !! Definition&lt;br /&gt;
|-&lt;br /&gt;
| DateTime || This returns the date/time of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| TimeInterval || This returns the duration, in half hours, of the current time step&lt;br /&gt;
|-&lt;br /&gt;
| Date || Date of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| TP || TP number of current Tick&lt;br /&gt;
|-&lt;br /&gt;
| Version || The number of the current version in the volatility matrix, numbered from zero&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
Operators are all pre-defined in EMarket. Their purpose is to separate a formula into parts that are then combined to give a single value.&lt;br /&gt;
&lt;br /&gt;
The following operators are shown in descending order of precedence.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Meaning !! Example !! Parameter Type !! Return Type&lt;br /&gt;
|-&lt;br /&gt;
| \ || Integer Division || 3\2 = 1 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| % || Modulus || 7%5 = 2 || Real; Int || Int&lt;br /&gt;
|-&lt;br /&gt;
| / || Division || 3/2 = 1.5 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| * || Multiplication || 5*4.2 = 21 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| - || Subtraction || 7-3.2 = 3.8 || Real; Int || Real&lt;br /&gt;
|-&lt;br /&gt;
| + || Addition || 3.5+1.5 = 5 || Real; Int || Real&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
Functions provide a powerful mechanism for deriving field and variable data values from input parameters.&lt;br /&gt;
&lt;br /&gt;
A function has the form FunctionName(Parameter1, Parameter2, ...)&lt;br /&gt;
&lt;br /&gt;
An operator is used in a Function in the following form: &amp;lt;Parameter1&amp;gt;Operator&amp;lt;Parameter2&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
EMarket provides the following function types:&lt;br /&gt;
*Arithmetic functions&lt;br /&gt;
*Logic functions&lt;br /&gt;
*Run information functions&lt;br /&gt;
*Time functions&lt;br /&gt;
*Other functions&lt;br /&gt;
&lt;br /&gt;
Note: Logic operators and functions evaluate to one for a result that is true (for example 6 = 6), and zero for false.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Arithmetic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| Sqrt || Square root of a number || Integer or Real || Real || Sqrt(546.94) || 23.387&lt;br /&gt;
|-&lt;br /&gt;
| Abs || Absolute value of a number || Integer or Real || Real || Abs(-19.1) || 19.1&lt;br /&gt;
|-&lt;br /&gt;
| Int || Integer portion of a number || Integer or Real || Integer || Int(45.786) || 45&lt;br /&gt;
|-&lt;br /&gt;
| Sum || Total value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Sum(Node.Price) ||&lt;br /&gt;
|-&lt;br /&gt;
| Max || Maximum value of numbers in an array, optionally excluding values with value over an exclude value || Value Array (Exclude Value), Integer or Real || Real || Max(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Min || Minimum value of numbers in an array ||  Value Array (Exclude Value), Integer or Real || Real || Min(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| StdDev || Standard deviation of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || StdDev(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| Avg || Average value of numbers in an array || Value Array (Exclude Value), Integer or Real || Real || Avg(Generator.Generation) ||&lt;br /&gt;
|-&lt;br /&gt;
| WgtAvg || Average of numbers in an array, weighted by numbers in another array || Value Array (Weights Array), Integer or Real || Real || WgtAvg(Generator.Generation,Generator.Cost) ||&lt;br /&gt;
|-&lt;br /&gt;
| Choke || Returns a collared value (i.e. the value of the referenced variable is returned if it falls within the specified range otherwise the relevant minimum or maximum value is returned) || Integer or Real || Real || Choke(500,200,Generator.Generation)||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Logic Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket3's Logic functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Operator !! Purpose !! Parameters !! Return Value !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| = || Whether two numbers are Equal || 2 numbers, Integer or Real || 0 or 1 || 5 = 6 || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || Whether first number is less than the second || 2 numbers, Integer or Real || 0 or 1 || -2 &amp;lt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || Whether first number is Greater than the second || 2 numbers, Integer or Real || 0 or 1 || 9 &amp;gt; 7 || 1&lt;br /&gt;
|-&lt;br /&gt;
| AND || Whether two numbers are both non-zero || 2 numbers, Integer or Real || 0 or 1 || And(6=6,4&amp;lt;3) || 0&lt;br /&gt;
|-&lt;br /&gt;
| OR || Whether either of two numbers are non-zero || 2 numbers, Integer or Real || 0 or 1 || OR(3&amp;lt;5, 2&amp;gt;3) || 1&lt;br /&gt;
|-&lt;br /&gt;
| Between || Whether a number is between two limits || Number: lower limit; upper limit, Integer, real or date || 0 or 1 || Between(5.7,9.7) || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Time Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's Time functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| GetDate || Converts a date to a day number || Date/Time || Integer || GetDate('1/4/2004') ||&lt;br /&gt;
|-&lt;br /&gt;
| hh || Gets the half hourly TP from a date || Date/Time || Integer || hh(DateTime) || &lt;br /&gt;
|-&lt;br /&gt;
| 4h || Gets the number of the block of 4 hourly trading periods for a given date (e.g. 1 = TP 1-8) || Date/Time || Integer || 4h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| 6h || Gets the number of the block of 6 hourly trading periods for a given date (e.g. 0 = TP 1-12) || Date/Time || Integer || 6h(DateTime) ||&lt;br /&gt;
|-&lt;br /&gt;
| DOW || Gets the weekday for a date, 0 = Sunday || Date/Time || Integer || Dow('14/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WO || Whether a date is a week day rather than a weekend or holiday, 1 = Weekend; 0 = Weekday || Date/Time || 0 or 1 || WO('13/6/2004') || 1&lt;br /&gt;
|-&lt;br /&gt;
| WODN || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF) || Date/Time || 0 to 3 || WODN('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| WODN6 || 0=Week Night(WN); 1=Week Day(WD); 2=Other Night(ON); 3=Other Day(OF). Using A night period running from Midnight to 6am (not to 8am as in WODN) || Date/Time || 0 to 3 || WODN6('1/5/2004 22:00') || 3&lt;br /&gt;
|-&lt;br /&gt;
| Month || Gets the month from a date, 0 = January || Date/Time || 0 to 11 || Month('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| WeekOfYear || Gets the week from a date, 0 = 1st full week in April || Date/Time || 0 to 51 || WeekOfYear('1/5/2004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateDiff || Calculates the number of days between two date/times || Date/Time, Date/Time  || Real || DateDiff('1/5/2004', '5/5/004') || 4&lt;br /&gt;
|-&lt;br /&gt;
| DateSeq || Gets the position of a required date within a list of ordered dates || Date/Time being looked up, List of Date/Time || Integer || DateSeq('5 / 4 / 2004', '1 / 4 / 2004', '2 / 4 / 2004', '3 / 4 / 2004', '4 / 4 / 2004', '5 / 4 / 2004') || 5&lt;br /&gt;
|-&lt;br /&gt;
| TimeSeries || Given a date ordered sequence of values, finds the value for a required date. Date format is Date:TimePeriod 'DD/MM/YYYY:TP' , if no TP then TP '01' is used || List of (Initial value, first date and time period applies for value2, value2 , ....) || Real || TimeSeries(735 , '1/04/2004:24',  760 , ' 1/04/2005',  840) || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Functions===&lt;br /&gt;
&lt;br /&gt;
The following table lists EMarket's other functions:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example !! Result&lt;br /&gt;
|-&lt;br /&gt;
| LastVal || Returns the value of the named variable in the last tick or, in the initial tick, a default value|| Variable Name, Default Value (Real or Integer) || Real || LastVal(Var, 100) || 100 in the first tick, the previous value of 'Var' in following ticks&lt;br /&gt;
|-&lt;br /&gt;
| ArrayTable || Uses two indices to retrieve a value from an array (matrix) || Index1, Index2, Value array. May be real or Integer || Real or Integer || ArrayTable(p,q,m,n, V00, V01, V02, ...V0m, V10,  V11, ... Vnm) where p,q represent the position of the array; m,n represent the numbers of columns and rows in the array; 0&amp;lt;= p &amp;lt; m and 0 &amp;lt;= q &amp;lt; n would return Vpq. &amp;lt;br/&amp;gt; E.g. ArrayTable(1, 1, 2, 3, 4, 32.1, 6.3, 1.8, 31, 5). This defines a 2 * 3 matrix, and looks for the entry indexed by 1, 1. Note that if the indices are out of bounds no error will be given, and an indeterminate value will be returned. || 31&lt;br /&gt;
|-&lt;br /&gt;
| Index || Gets the number in given position (index) in a list of numbers. First number has position zero. || 1 or more numbers, can be integers or real || Real || Index(p, V0, V1, V2, ... Vm) where p is the position (index) in a list of numbers.&amp;lt;br/&amp;gt; E.g. Index(3, 4.5, 7, 8.9, -23.4) || -23.4&lt;br /&gt;
|-&lt;br /&gt;
| PieceWiseLinear || Generates a value based on an extrapolation of existing data. Given a target value (p) and a set of x, y pairings defining a function, the PieceWiseLinear function will find the y value corresponding to p. This function is included primarily for use in defining Demand elasticity. || Set of x,y value pairings, can be integers or real || Real or Integer || PieceWiseLinear(p, x1, y1, x2, y2, ...xn, yn) where p is the target value. Note that you can use internal model variables as the target value, as in this example: &amp;lt;br/&amp;gt;PieceWiseLinear(HydroSystem:Waitaki.SystemMWV, 0, 1, 80, 1, 150, 0.8, 400, 0.64) ||&lt;br /&gt;
|-&lt;br /&gt;
| FileInput|| This function accesses a CSV file in the 'Misc' subdirectory of the data directory and returns values from this file.  This file will a set of time dependent value series which are each given a series number (e.g. inflow years).   The format of the input file can be found in '''''[[EMK:Ancillary Files | Ancillary Files]]''''' || The file name string, the date for which a value is being looked up,  the integer series number || Real or Integer || FileInput(&amp;quot;MyGenCapacity.csv&amp;quot;, DateTime, InflowYearNo) ||&lt;br /&gt;
|-&lt;br /&gt;
| CurrentInflowYear || Returns the year of the inflow sequence being used given the starting inflow year and the current date/time  || Current Date/Time, Inflow Sequence (integer) || Integer || CurrentInflowYear(DateTime, InflowYear)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Random Functions===&lt;br /&gt;
&lt;br /&gt;
the following random functions create a random sequence, the results of which depend on the seed given, the start date of the sequence and the order of definition and exact formula used to define the function.  The RandomSeed variable should usually be used as the seed as this will ensure a unique sequence is generated based on the &amp;quot;Random Seed&amp;quot; option chosen for the run&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Function !! Purpose !! Parameters !! Return Type !! Example &lt;br /&gt;
|-&lt;br /&gt;
| RandomBinaryState || Returns values from a random sequence of values which are either 0 or 1 with the properties that proportion of the time spent in the zero state is a given proportion and the average length of time spent in the one state is a given number of days || Seed for random sequence, Date/Time, Zero state proportion, Average One state length || Real ||  RandomBinaryState(Seed, DateTime, 0.95, 4), will return a random 0/1 series with 0.05 time spent in the one state and an average four day span of each one state&lt;br /&gt;
|-&lt;br /&gt;
| MRJD || Returns a value that follows a mean reverting random walk on a logarithmic scale || Seed for random sequence, Date/Time, Starting Value, Mean, Reversion Rate, Volatility[,ProportionalJump, JumpVolatility, JumpFrequency] || Real ||MRJD(RandomSeed, DateTime, 5, 10, 11, 5), will return a random walk starting with the value 5 where the average log value is equal to log(10), reversion rate of 10 (half reversion in 1/10 year), volatility of 5 (two times diffusion in 1/5 year).  The jump parameters are optional&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[EMK:EMarket User Manual | Back to User Manual Main Page]]&lt;/div&gt;</summary>
		<author><name>WoodsM</name></author>
	</entry>
</feed>