Logo GenPRES

Maximum Module

Creates an inclusive or exclusive maximum from a single value, compares and restricts maximums, and rounds a maximum down to a multiple of an increment. Raises a solver exception when the ValueUnit does not hold a single value.

Functions and values

Function or value Description

apply fIncl fExcl _arg1

Full Usage: apply fIncl fExcl _arg1

Parameters:
    fIncl : ValueUnit -> 'a - The function to apply to an inclusive Maximum
    fExcl : ValueUnit -> 'a - The function to apply to an exclusive Maximum
    _arg1 : Maximum

Returns: 'a
Type parameters: 'a

Apply fIncl or fExcl to the BigRational value of Maximum

fIncl : ValueUnit -> 'a

The function to apply to an inclusive Maximum

fExcl : ValueUnit -> 'a

The function to apply to an exclusive Maximum

_arg1 : Maximum
Returns: 'a

checkOverflow max

Full Usage: checkOverflow max

Parameters:

Check if either the numerator or denominator of the Maximum is too large, i.e., there is an 'overflow'.

In theory a Maximum can have a numerator or denominator of any size. However, in practice, this will lead to performance issues. Therefore, we limit the size of the numerator and denominator to a maximum value.

max : Maximum

convertTo max

Full Usage: convertTo max

Parameters:
Returns: Maximum -> Maximum

Convert the Unit of a Maximum to the Unit of the second Maximum.

max : Maximum
Returns: Maximum -> Maximum
Example

 let max1 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 let max2 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.milliGram)
 max1 |> Maximum.convertTo max2
 // returns Maximum (ValueUnit ([|3000N|], Mass (MilliGram 1N)))
val max1: obj
val max2: obj

create isIncl vu

Full Usage: create isIncl vu

Parameters:
    isIncl : bool - Whether the Maximum is inclusive or exclusive
    vu : ValueUnit - The ValueUnit

Returns: Maximum A Maximum

Create a Maximum that is either inclusive or exclusive.

isIncl : bool

Whether the Maximum is inclusive or exclusive

vu : ValueUnit

The ValueUnit

Returns: Maximum

A Maximum

Exceptions.ValueRangeEmptyMaximumException When the ValueUnit is empty of has more than one value

eqs max1 max2

Full Usage: eqs max1 max2

Parameters:
    max1 : Maximum - The first Maximum
    max2 : Maximum - The second Maximum

Returns: bool

Check if 'max1' equals 'max2'

Uses ValueUnit equality, so 1000 milligram equals 1 gram. Also takes into account whether the Maximum is inclusive or exclusive.

max1 : Maximum

The first Maximum

max2 : Maximum

The second Maximum

Returns: bool

hasZeroUnit

Full Usage: hasZeroUnit

Returns: Maximum -> bool

Checks whether the Maximum has a ZeroUnit.

Returns: Maximum -> bool

isExcl _arg1

Full Usage: isExcl _arg1

Parameters:
Returns: bool

Checks whether Maximum is exclusive.

_arg1 : Maximum
Returns: bool

isIncl

Full Usage: isIncl

Returns: Maximum -> bool

Checks whether Maximum is inclusive.

Returns: Maximum -> bool

map fIncl fExcl

Full Usage: map fIncl fExcl

Parameters:
Returns: Maximum -> Maximum

Map fIncl or fExcl to the BigRational value of Maximum

fIncl : ValueUnit -> ValueUnit

The function to apply to an inclusive Maximum

fExcl : ValueUnit -> ValueUnit

The function to apply to an exclusive Maximum

Returns: Maximum -> Maximum

maxElement

Full Usage: maxElement

Returns: ValueUnit -> Maximum option

Creates a Maximum from a ValueUnit. Returns None if an empty set.

Returns: ValueUnit -> Maximum option

maxGTEmax maxRight maxLeft

Full Usage: maxGTEmax maxRight maxLeft

Parameters:
Returns: bool

Checks whether Maximum maxLeft >= maxRight

Note that the fact that a Maximum is inclusive or exclusive must be taken into account.

maxRight : Maximum
maxLeft : Maximum
Returns: bool
Example

 let max1 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 let max2 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxGTEmax max1 // returns true

 // make max2 exclusive
 let max2 = Maximum.create false ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxGTEmax max1 // returns false!
val max1: obj
val max2: obj

maxGTmax maxRight maxLeft

Full Usage: maxGTmax maxRight maxLeft

Parameters:
Returns: bool

Checks whether Maximum maxLeft > maxRight

Note that the fact that a Maximum is inclusive or exclusive must be taken into account.

maxRight : Maximum
maxLeft : Maximum
Returns: bool
Example

 let max1 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 let max2 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxGTmax max1 // returns false

 // make max1 exclusive
 let max1 = Maximum.create false ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxGTmax max1 // returns true!
val max1: obj
val max2: obj

maxSTEmax maxRight maxLeft

Full Usage: maxSTEmax maxRight maxLeft

Parameters:
Returns: bool

Checks whether Maximum maxLeft <= maxRight

Note that the fact that a Maximum is inclusive or exclusive must be taken into account.

maxRight : Maximum
maxLeft : Maximum
Returns: bool
Example

 let max1 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 let max2 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxSTEmax max1 // returns true

 // make max1 exclusive
 let max1 = Maximum.create false ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxSTEmax max1 // returns false!
val max1: obj
val max2: obj

maxSTmax maxRight maxLeft

Full Usage: maxSTmax maxRight maxLeft

Parameters:
Returns: bool

Checks whether Maximum maxLeft < maxRight

Note that the fact that a Maximum is inclusive or exclusive must be taken into account.

maxRight : Maximum
maxLeft : Maximum
Returns: bool
Example

 let max1 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 let max2 = Maximum.create true ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxSTmax max1 // returns false

 // make max2 exclusive
 let max2 = Maximum.create false ( [| 3N |] |> ValueUnit.create Units.Mass.gram)
 max2 |> Maximum.maxSTmax max1 // returns true!
val max1: obj
val max2: obj

multipleOf incr max

Full Usage: multipleOf incr max

Parameters:
Returns: Maximum

Recalculate the maximum value of a Maximum as a multiple of incr.

The recalculated maximum is always inclusive as it has to be a multiple of the increment.

incr : Increment

The increment

max : Maximum

The maximum

Returns: Maximum
Example

 let incr = Increment.create ( [| 2N |] |> ValueUnit.create Units.Mass.gram)
 let max = Maximum.create false ( [| 5N |] |> ValueUnit.create Units.Mass.gram)
 max |> Maximum.multipleOf incr
 // returns Maximum (ValueUnit ([|4N|], Mass (Gram 1N)))
val incr: obj
val max: obj

nonZeroAndPositive max

Full Usage: nonZeroAndPositive max

Parameters:
Returns: Minimum * Maximum

Make a Maximum non-zero and non-negative.

max : Maximum
Returns: Minimum * Maximum

restrict newMax oldMax

Full Usage: restrict newMax oldMax

Parameters:
    newMax : Maximum - The new maximum
    oldMax : Maximum - The old maximum

Returns: Maximum The restricted maximum. This is the old maximum if the new maximum is greater than the old maximum, or the new maximum if the new maximum is smaller than the old maximum.

Restrict an oldMax with a newMax. Effectively this means that the newMax is the new maximum if it is smaller than the old maximum.

newMax : Maximum

The new maximum

oldMax : Maximum

The old maximum

Returns: Maximum

The restricted maximum. This is the old maximum if the new maximum is greater than the old maximum, or the new maximum if the new maximum is smaller than the old maximum.

setUnit u

Full Usage: setUnit u

Parameters:
    u : Unit - The unit to set

Returns: Maximum -> Maximum

Convert the unit of a Maximum to u.

u : Unit

The unit to set

Returns: Maximum -> Maximum

toBoolValueUnit

Full Usage: toBoolValueUnit

Returns: Maximum -> bool * ValueUnit

Convert a Maximum to a ValueUnit and a bool that signifies inclusive or exclusive

Returns: Maximum -> bool * ValueUnit

toMarkdown prec max

Full Usage: toMarkdown prec max

Parameters:
    prec : int - The precision
    max : Maximum - The maximum

Returns: string

Get the markdown representation of a Maximum.

prec : int

The precision

max : Maximum

The maximum

Returns: string

toString exact max

Full Usage: toString exact max

Parameters:
    exact : bool - Print exact or not
    max : Maximum - The maximum

Returns: string

Get the string representation of a Maximum.

exact : bool

Print exact or not

max : Maximum

The maximum

Returns: string

toValueUnit _arg1

Full Usage: toValueUnit _arg1

Parameters:
Returns: ValueUnit

Convert a Maximum to a ValueUnit.

_arg1 : Maximum
Returns: ValueUnit

Type something to start searching.