Logo GenPRES

Equation Module

Creates, inspects and solves an equation whose first variable is the product or the sum of the other variables.

Nested modules

Modules Description

Dto

Holds the Dto of an equation and converts an equation to and from the Dto. Raises a solver exception for an empty variable list or duplicate variables.

SolveResult

Writes a solve result as text: unchanged, the changed variables with the changed properties, or the errors.

Functions and values

Function or value Description

apply fp fs _arg1

Full Usage: apply fp fs _arg1

Parameters:
Returns: 'a
Type parameters: 'a

Apply fp to a ProductEquation and fs to a SumEquation.

fp : Variable -> Variable list -> 'a
fs : Variable -> Variable list -> 'a
_arg1 : Equation
Returns: 'a

calculationToString b op1 op2 y xs

Full Usage: calculationToString b op1 op2 y xs

Parameters:
Returns: string

Get the string representation of a calculation

b : bool
op1 : Variable -> Variable -> Variable
op2 : Variable -> Variable -> Variable
y : Variable
xs : Variable list
Returns: string

check onlyMinIncrMax eq

Full Usage: check onlyMinIncrMax eq

Parameters:
    onlyMinIncrMax : bool - Only calculate min/incr/max
    eq : Equation - The equation

Returns: bool

Check whether an equation is valid

onlyMinIncrMax : bool

Only calculate min/incr/max

eq : Equation

The equation

Returns: bool

contains v

Full Usage: contains v

Parameters:
Returns: Equation -> bool

Check whether an Equation contains a Variable v

v : Variable
Returns: Equation -> bool

count onlyMinMax eq

Full Usage: count onlyMinMax eq

Parameters:
    onlyMinMax : bool - Whether only min max is used
    eq : Equation - The equation

Returns: int

Get the count of Variables in an Equation

onlyMinMax : bool

Whether only min max is used

eq : Equation

The equation

Returns: int

countProduct eq

Full Usage: countProduct eq

Parameters:
Returns: int

Get product of the Variables in an Equation

eq : Equation
Returns: int

create c succ fail (y, xs)

Full Usage: create c succ fail (y, xs)

Parameters:
Returns: 'b
Type parameters: 'a, 'b

Create an Equation with an y and xs. Fails if a variable is added more than one time using the fail function. The type of Equation product or sum is determined by the constructor c.

c : Variable * Variable list -> 'a
succ : 'a -> 'b
fail : Message -> 'b
y : Variable
xs : Variable list
Returns: 'b

createProductEq

Full Usage: createProductEq

Returns: (Equation -> Equation) -> (Message -> Equation) -> Variable * Variable list -> Equation

Create a ProductEquation with an y and xs. Fails if a variable is added more than one time using the fail function.

Returns: (Equation -> Equation) -> (Message -> Equation) -> Variable * Variable list -> Equation

createProductEqExc

Full Usage: createProductEqExc

Returns: Variable * Variable list -> Equation

Create a ProductEquation with an y and xs. Fails if a variable is added more than one time, raising an exception.

Returns: Variable * Variable list -> Equation

createSumEq

Full Usage: createSumEq

Returns: (Equation -> Equation) -> (Message -> Equation) -> Variable * Variable list -> Equation

Create a SumEquation with an y and xs. Fails if a variable is added more than one time using the fail function.

Returns: (Equation -> Equation) -> (Message -> Equation) -> Variable * Variable list -> Equation

createSumEqExc

Full Usage: createSumEqExc

Returns: Variable * Variable list -> Equation

Create a SumEquation with an y and xs. Fails if a variable is added more than one time, raising an exception.

Returns: Variable * Variable list -> Equation

equals eq1 eq2

Full Usage: equals eq1 eq2

Parameters:
Returns: bool

Check whether Equations eq1 and eq2 are equal

eq1 : Equation
eq2 : Equation
Returns: bool

find var eq

Full Usage: find var eq

Parameters:
Returns: Variable list

Find a Variable vr in an Equation eq and return the result in a list

var : Variable
eq : Equation
Returns: Variable list

findName n eq

Full Usage: findName n eq

Parameters:
Returns: Variable list

Find a Variable with Name n in an Equation eq and return the result as a list

n : Name
eq : Equation
Returns: Variable list

hasSumUnitMismatch eq

Full Usage: hasSumUnitMismatch eq

Parameters:
Returns: bool

True when a sum equation holds variables with a known unit in more than one unit group, so the values cannot be added. A variable without a unit, or with the dimensionless zero unit, matches any unit, as in the addition of two value units. A product equation is never a mismatch, as any two units can be multiplied or divided.

eq : Equation
Returns: bool

isProduct

Full Usage: isProduct

Returns: Equation -> bool

Check whether an Equation is a product equation

Returns: Equation -> bool

isSolvable _arg1

Full Usage: isSolvable _arg1

Parameters:
Returns: bool

Check whether an equation will change by calc This is different from isSolved!! If all the variables are unrestricted, then the equation is not solvable but is also not solved.

_arg1 : Equation
Returns: bool

isSolved _arg1

Full Usage: isSolved _arg1

Parameters:
Returns: bool

Check whether an equation is solved

_arg1 : Equation
Returns: bool

isSum

Full Usage: isSum

Returns: Equation -> bool

Check whether an Equation is a sum equation

Returns: Equation -> bool

nonZeroOrNegative eq

Full Usage: nonZeroOrNegative eq

Parameters:
Returns: Equation

Make sure that the Variables in the Equation can only contain positive non-zero values.

eq : Equation
Returns: Equation

replace var eq

Full Usage: replace var eq

Parameters:
Returns: Equation

Replace a Variable v in the Equation e.

var : Variable
eq : Equation
Returns: Equation

solve onlyMinIncrMax log eq

Full Usage: solve onlyMinIncrMax log eq

Parameters:
    onlyMinIncrMax : bool - Calculate only Min, Incr and Max if true
    log : Logger - The logger to log solving steps
    eq : Equation - The equation

Returns: Equation * SolveResult The resulting equation and the changed variables

Solve an equation eq and return the resulting eq with the variables that were changed as a SolveResult

onlyMinIncrMax : bool

Calculate only Min, Incr and Max if true

log : Logger

The logger to log solving steps

eq : Equation

The equation

Returns: Equation * SolveResult

The resulting equation and the changed variables

Exceptions.SolverException If solving the equation runs into an error

toString exact eq

Full Usage: toString exact eq

Parameters:
Returns: string

Get the string representation of an Equation

exact : bool
eq : Equation
Returns: string

toStringShort eq

Full Usage: toStringShort eq

Parameters:
Returns: string

Get the string representation of an Equation

eq : Equation
Returns: string

toVars

Full Usage: toVars

Returns: Equation -> Variable list

Turn an Equation into a list of Variable

Returns: Equation -> Variable list

Type something to start searching.