﻿ G: Price & Cost Formulas

# G: Price & Cost Formulas

The market simulator can use simple numeric values in the Profits and Revenues dialog for calculating cost and price.  However, formulas and user-defined variables can also be used.

The syntax for formulas is similar to syntax in Microsoft Excel, where formulas begin with an equals ('=') sign.  Similar to Excel, functions can be used and be embedded within another to create the desired result.

The following operators can be used in formulas:

Mathematical:  '+' (addition), '-' (subtraction), '*' (multiplication), '/' (division), '^' (power), '%' (modulo)

Comparison: '=' (boolean equals), '<>' (boolean not-equal), '>' (greater than), '<' (less than), '>=' (greater than or equal), '<=' (less than or equal)

Example of a formula:

=if(totalvolume*share() > volumetier1, costtier1, costtier2)In this example, we assume four user-defined variables have been created by the user in advance: 'totalvolume', 'volumetier1', 'costtier1', and 'costtier2'.  The if() function is checking to see if the product's share multiplied by totalvolume is greater than volumetier1.  If so, then use the value of costtier1.  Otherwise use the value of costtier2.

User-defined variables can be defined using the User-defined Variables within the Profits and Revenues dialog.  A label for the variable goes in the Label column, and the corresponding value should be added in the Value column.  User-defined variables can include formulas and reference other user-defined variables.  However, a user-defined variable must evaluate to a single value during simulation, or an error will occur.  Examples:

Label                Value

volumetier1        100000

volumetier2        =volumetier1 * 0.75

The following functions are available for use within formulas:

Mathematical Functions

Abs(x)

Returns the absolute value of the specified value.  Usage:

=abs(-3.141)

Average(x,y,z)

Returns the average of the specified values.  This function can be used with any number of values, but requires at least one.  Usage:

=average(1, 2, 10)

E()

Returns the value of the numeric constant e.  Usage:

=e()

Exp(x)

Returns e raised to the specified power (i.e. e^x).  Usage:

=exp(3.141)

Log(x,base)

Returns the logarithm of a specified value in a specified base.  Usage:

=log(1000, 10)

Ln(x)

Returns the natural log of a specified value.  Usage:

=ln(3.141)

Max(x,y,z)

Returns the maximum of the specified values.  This function can be used with any number of values, but requires at least two.  Usage:

=max(10, 100, 1000)

Min(x,y,z)

Returns the minimum of the specified values.  This function can be used with any number of values, but requires at least two.  Usage:

=min(10, 100, 1000)

Pi()

Returns the value of the numeric constant pi.  Usage:

=pi()

Product(x,y,z)

Returns the product (multiplication) of the specified values.  This function can be used with any number of values, but requires at least two.  Usage:

=product(5, 10, 15)

Sum(x,y,z)

Returns the sum (addition) of the specified values.  This function can be used with any number of values, but requires at least two.  Usage:

=sum(5, 10, 15)

Sqrt(x)

Returns the square root of a specified value.  Usage:

=sqrt(3.141)

Logical Functions

And(x,y,z)

Returns true if all values evaluate to true; false otherwise.  This function can be used with any number of values, but requires at least two.  Usage:

=and(x=2,y=3,z=4)

Or(x,y,z)

Returns true if any values evaluate to true; false otherwise.  This function can be used with any number of values, but requires at least two.  Usage:

=and(x=2,y=3,z=4)

Not(x)

Returns the opposite of the specified boolean value.  Usage:

=not(x)

If(x,y,z)

If x is true, then y is returned; otherwise z is returned.  Usage:

=if(x=2, 3, 4)

Reference Functions

Share()

Returns the share for the product at simulation time.  Note: This function is provided for informational purposes, and should not be used as a scaling factor in determining price or cost as those values are already multiplied by share in the simulation results.  Usage:

=share()