Logo GenPRES

Variable Module

Creates a variable with a name and a value range, restricts and calculates with the value range, and sets the variable to a single value.

Nested modules

Modules Description

Dto

Holds the Dto of a variable and converts a variable to and from the Dto. Raises a solver exception for an invalid name or an invalid value range.

Name

Creates the name of a variable from a string and writes the name as text. Fails for a blank string or a string longer than 1000 characters.

Operators

Holds the operators to calculate with two variables and to restrict a variable, the constants 1, 2 and 3, and the text of an operator.

ValueRange

Creates a value range, restricts the range with a minimum, increment, maximum or value set, and calculates with two value ranges.

Functions and values

Function or value Description

apply f var

Full Usage: apply f var

Parameters:
Returns: 'a
Type parameters: 'a

Apply f to Variable var.

f : Variable -> 'a
var : Variable
Returns: 'a

calc op (v1, v2)

Full Usage: calc op (v1, v2)

Parameters:
Returns: Variable

Apply the operator op to v1 and v2 return an intermediate *result* Variable.

op : ValueRange -> ValueRange -> ValueRange
v1 : Variable
v2 : Variable
Returns: Variable

clear var

Full Usage: clear var

Parameters:
Returns: Variable

Clear all restrictions on the values of a Variable by setting the ValueRange to Unrestricted

var : Variable
Returns: Variable

contains v vr

Full Usage: contains v vr

Parameters:
Returns: bool

Check whether a Variable v contains a value v.

v : ValueUnit
vr : Variable
Returns: bool

convertToUnit unit var

Full Usage: convertToUnit unit var

Parameters:
Returns: Variable

Set the unit of a Variable

unit : Unit
var : Variable
Returns: Variable

count v

Full Usage: count v

Parameters:
Returns: int

Get the number of distinct values Note that the valuerange has to be a ValueSet to get a count

v : Variable
Returns: int

create succ n vs

Full Usage: create succ n vs

Parameters:
Returns: 'a
Type parameters: 'a

Create a Variable and passes the result to succ

succ : Variable -> 'a
n : Name
vs : ValueRange
Returns: 'a

createRes

Full Usage: createRes

Returns: ValueRange -> Variable

Helper create function to store the result of a Variable calculation before applying to the actual result Variable.

Returns: ValueRange -> Variable

createSucc

Full Usage: createSucc

Returns: Name -> ValueRange -> Variable

Create a Variable and directly return the result.

Returns: Name -> ValueRange -> Variable

empty n

Full Usage: empty n

Parameters:
Returns: Variable

A Variable with an Unrestricted ValueRange

n : Name
Returns: Variable

eqName v1 v2

Full Usage: eqName v1 v2

Parameters:
Returns: bool

Checks whether v1 and v2 have the same Name

v1 : Variable
v2 : Variable
Returns: bool

eqValues var1 var2

Full Usage: eqValues var1 var2

Parameters:
Returns: bool

Check whether the ValueRange of v1 and v2 are equal.

var1 : Variable
var2 : Variable
Returns: bool

eqsUnitGroup var1 var2

Full Usage: eqsUnitGroup var1 var2

Parameters:
Returns: bool
var1 : Variable
var2 : Variable
Returns: bool

get

Full Usage: get

Returns: Variable -> Variable

Helper function for type inference

Returns: Variable -> Variable

getName v

Full Usage: getName v

Parameters:
Returns: Name

Get the Name of a Variable.

v : Variable
Returns: Name

getUnit var

Full Usage: getUnit var

Parameters:
Returns: Unit option

Get the unit of a Variable

var : Variable
Returns: Unit option

getValueRange v

Full Usage: getValueRange v

Parameters:
Returns: ValueRange

Get the ValueRange of a Variable.

v : Variable
Returns: ValueRange

hasValues var

Full Usage: hasValues var

Parameters:
Returns: bool

Checks whether a Variable has values (and therefore is a ValueSet).

var : Variable
Returns: bool

increaseIncrement maxCount incrs var

Full Usage: increaseIncrement maxCount incrs var

Parameters:
Returns: Variable The resulting (more restrictive) ValueRange

Try and increase the increment of a ValueRange of a Variable to an increment in incrs such that the resulting ValueRange contains at most maxCount values.

When there is no increment in the list that can be used to increase the increment of the ValueRange to the maximum count, the largest possible increment is used.

maxCount : RationalX

The maximum count

incrs : Increment list

The increment list

var : Variable

The Variable

Returns: Variable

The resulting (more restrictive) ValueRange

isMax

Full Usage: isMax

Returns: Variable -> bool

Checks whether the ValueRange of a Variable is a Maximum

Returns: Variable -> bool

isMin

Full Usage: isMin

Returns: Variable -> bool

Checks whether the ValueRange of a Variable is a Minimum

Returns: Variable -> bool

isMinExclusiveZero

Full Usage: isMinExclusiveZero

Returns: Variable -> bool

Checks whether the ValueRange of a Variable Minimum is exclusive zero

Returns: Variable -> bool

isMinIncr

Full Usage: isMinIncr

Returns: Variable -> bool

Checks whether the ValueRange of a Variable is an MinIncr

Returns: Variable -> bool

isMinIncrMax

Full Usage: isMinIncrMax

Returns: Variable -> bool

Checks whether the ValueRange of a Variable is a MinIncrMax

Returns: Variable -> bool

isMinMax

Full Usage: isMinMax

Returns: Variable -> bool

Checks whether the ValueRange of a Variable is a MinMax

Returns: Variable -> bool

isNonZeroPositive

Full Usage: isNonZeroPositive

Returns: Variable -> bool

Checks whether the ValueRange of a Variable is non-zero and positive

Returns: Variable -> bool

isSolvable

Full Usage: isSolvable

Returns: Variable -> bool

Checks whether a Variable is *solvable* i.e., can be further restricted to one value (or no values at all)

Returns: Variable -> bool

isSolved var

Full Usage: isSolved var

Parameters:
Returns: bool

Checks whether a Variable v is solved, i.e., there is but one possible value left.

var : Variable
Returns: bool

isUnrestricted

Full Usage: isUnrestricted

Returns: Variable -> bool

Checks whether there are no restrictions to possible values a Variable can contain

Returns: Variable -> bool

isValSet

Full Usage: isValSet

Returns: Variable -> bool

Checks whether the ValueRange of a Variable is a ValSet

Returns: Variable -> bool

minIncrMaxToValues steps n var

Full Usage: minIncrMaxToValues steps n var

Parameters:
    steps : ValueUnit list - The rounded steps the prune keeps the multiples of
    n : int option - Prune the ValueSet to n
    var : Variable - The variable to change min incr max to a ValueSet

Returns: Variable A Variable with a ValueSet if this can be calculated

Calculate a ValueSet for a Variable if the Value of the Variable is a MinIncrMax

steps : ValueUnit list

The rounded steps the prune keeps the multiples of

n : int option

Prune the ValueSet to n

var : Variable

The variable to change min incr max to a ValueSet

Returns: Variable

A Variable with a ValueSet if this can be calculated

nearestNth find round target var

Full Usage: nearestNth find round target var

Parameters:
Returns: int option

Returns the place, counted from 0, of the value of a variable nearest to the target. In a value set, find returns the place from the target and the values. In a min, increment and max with a value count, round makes a whole number of the increments from the min to the target; a target below the min gives the first place and a target above the max the last place. Returns None when the target is not a single value, and for a variable without a value set and without a value count.

find : BigRational -> BigRational[] -> int
round : RationalX -> RationalX
target : ValueUnit
var : Variable
Returns: int option

nearestNthAtLeast target var

Full Usage: nearestNthAtLeast target var

Parameters:
Returns: int option

Returns the place of the lowest value of a variable at or above the target, or the last place when the target is above every value. Returns None when nearestNth finds no place.

target : ValueUnit
var : Variable
Returns: int option

nearestNthAtMost target var

Full Usage: nearestNthAtMost target var

Parameters:
Returns: int option

Returns the place of the highest value of a variable at or below the target, or the first place when the target is below every value. Returns None when nearestNth finds no place.

target : ValueUnit
var : Variable
Returns: int option

raiseExc errs m

Full Usage: raiseExc errs m

Parameters:
Returns: 'a
Type parameters: 'a
errs : Message list
m : Message
Returns: 'a

setMaxValue var

Full Usage: setMaxValue var

Parameters:
    var : Variable - The Variable to set the maximum value for.

Returns: Variable The Variable with the new maximum value.

Set the maximum value of a Variable.

var : Variable

The Variable to set the maximum value for.

Returns: Variable

The Variable with the new maximum value.

setMedianValue var

Full Usage: setMedianValue var

Parameters:
    var : Variable - The Variable to set the median value for.

Returns: Variable The Variable with the new median value.

Set the median value of a Variable.

var : Variable

The Variable to set the median value for.

Returns: Variable

The Variable with the new median value.

setMinValue var

Full Usage: setMinValue var

Parameters:
    var : Variable - The Variable to set the minimum value for.

Returns: Variable The Variable with the new minimum value.

Set the minimum value of a Variable.

var : Variable

The Variable to set the minimum value for.

Returns: Variable

The Variable with the new minimum value.

setName n v

Full Usage: setName n v

Parameters:
Returns: Variable

Change Name to n.

n : Name
v : Variable
Returns: Variable

setNearestValueAtLeast target var

Full Usage: setNearestValueAtLeast target var

Parameters:
Returns: Variable

The variable set to its lowest value at or above the target, or to its last value when the target is above every value. The variable is kept as it is when nearestNth finds no place.

target : ValueUnit
var : Variable
Returns: Variable

setNearestValueAtMost floor target var

Full Usage: setNearestValueAtMost floor target var

Parameters:
Returns: Variable

The variable set to its highest value at or below the target, but not below its lowest value at or above the floor. The variable is kept as it is when nearestNth finds no place for the target or for the floor.

floor : ValueUnit
target : ValueUnit
var : Variable
Returns: Variable

setNonZeroAndPositive v

Full Usage: setNonZeroAndPositive v

Parameters:
Returns: Variable

Set the values to a ValueRange that prevents zero or negative values.

v : Variable
Returns: Variable

setNthValue nth var

Full Usage: setNthValue nth var

Parameters:
Returns: Variable

The variable set to its nth value, counted from 0: the nth of its value set, or min plus nth times the increment, capped at the maximum. A value set without an nth value is kept as it is.

nth : int
var : Variable
Returns: Variable

setPercValue perc var

Full Usage: setPercValue perc var

Parameters:
Returns: Variable

The variable set to the value at perc percent of the way through its values: 0 gives the first value and 100 the last. A variable without a value count is kept as it is.

perc : int
var : Variable
Returns: Variable

setUnit unt var

Full Usage: setUnit unt var

Parameters:
    unt : Unit - The unit to set.
    var : Variable - The Variable to set the unit for.

Returns: Variable The Variable with the new unit.

Set the unit of a Variable.

unt : Unit

The unit to set.

var : Variable

The Variable to set the unit for.

Returns: Variable

The Variable with the new unit.

setValueRange vr var

Full Usage: setValueRange vr var

Parameters:
Returns: Variable

Apply a ValueRange vr to Variable v.

vr : ValueRange
var : Variable
Returns: Variable

toString exact arg2

Full Usage: toString exact arg2

Parameters:
Returns: string

Get the string representation of a Variable.

exact : bool
arg1 : Variable
Returns: string

toStringShort arg1

Full Usage: toStringShort arg1

Parameters:
Returns: string

Get the string representation of a Variable.

arg0 : Variable
Returns: string

valueCount var

Full Usage: valueCount var

Parameters:
Returns: int option

The number of values of a variable: of its value set, or of its min, increment and max when the increment has one value; None for any other range.

var : Variable
Returns: int option

Type something to start searching.