Logo GenPRES

Increment Module

Creates an increment from the positive values of a ValueUnit, removing multiples of a smaller value, and restricts and calculates with increments. Raises a solver exception for an empty increment.

Functions and values

Function or value Description

apply f arg2

Full Usage: apply f arg2

Parameters:
Returns: 'a The result of applying f to the ValueUnit
Type parameters: 'a

Apply a function over the ValueUnit of Increment.

f : ValueUnit -> 'a

The function to apply

arg1 : Increment
Returns: 'a

The result of applying f to the ValueUnit

calc op incr1 incr2

Full Usage: calc op incr1 incr2

Parameters:
Returns: Increment option

Calculates the resulting increment of a calculation with op in an equation: y = x1 op x2, where incr1 is the increment of x1, incr2 is the increment of x2 and y.incr is the resulting increment.

An increment can only be calculated when the operator is multiplication or addition with equal increments.

op : ValueUnit -> ValueUnit -> ValueUnit

The operator, can be mult, div, add, sub

incr1 : ValueUnit

Increment 1

incr2 : ValueUnit

Increment 2

Returns: Increment option

calcOpt op incr1 incr2

Full Usage: calcOpt op incr1 incr2

Parameters:
Returns: Increment option The resulting increment or None if the increment cannot be calculated.

Calculate an increment with incr1 of x1 and incr2 of x2 in an equation: y = x1 op x2

An increment can only be calculated when the operator is multiplication or addition with equal increments.

op : ValueUnit -> ValueUnit -> ValueUnit
incr1 : Increment option
incr2 : Increment option
Returns: Increment option

The resulting increment or None if the increment cannot be calculated.

convertToUnit u

Full Usage: convertToUnit u

Parameters:
    u : Unit - The unit to convert to

Returns: Increment -> Increment

Convert the Unit of an Increment to u.

u : Unit

The unit to convert to

Returns: Increment -> Increment

count arg1

Full Usage: count arg1

Parameters:
Returns: int

Get the number of values in the increment

arg0 : Increment
Returns: int

create vu

Full Usage: create vu

Parameters:
Returns: Increment An Increment

Creates an Increment from a ValueUnit.

Filters out negative values and removes multiples.

vu : ValueUnit

The ValueUnit

Returns: Increment

An Increment

Exceptions.ValueRangeEmptyIncrementException When the ValueUnit is empty

eqs incr1 incr2

Full Usage: eqs incr1 incr2

Parameters:
Returns: bool

Check if 'incr1' equals 'incr2'

incr1 : Increment

The first increment

incr2 : Increment

The second increment

Returns: bool
Example

Uses ValueUnit equality, so 1000 milligram equals 1 gram

 let incr1 = Increment.create ( [| 1000N |] |> ValueUnit.create Units.Mass.milliGram)
 let incr2 = Increment.create ( [| 1N |] |> ValueUnit.create Units.Mass.gram)
 incr1 |> Increment.eqs incr2
 // returns true, i.e. 1000 milligram equals 1 gram
val incr1: obj
val incr2: obj

intersect arg1 arg2

Full Usage: intersect arg1 arg2

Parameters:
Returns: Increment The intersection of the two increments.

Get the intersection of two Increment.

Returns the ValueUnit with Unit of the first increment.

arg0 : Increment
arg1 : Increment
Returns: Increment

The intersection of the two increments.

Example

 let incr1 = Increment.create ( [| 2000N; 3000N |] |> ValueUnit.create Units.Mass.milliGram)
 let incr2 = Increment.create ( [| 3N; 5N |] |> ValueUnit.create Units.Mass.gram)
 incr1 |> Increment.intersect incr2
 // returns Increment (ValueUnit ([|3000N|], Mass (MilliGram 1N)))
val incr1: obj
val incr2: obj

isEmpty arg1

Full Usage: isEmpty arg1

Parameters:
Returns: bool

Check if the increment is empty, i.e., has no values

arg0 : Increment
Returns: bool

isMultipleOf incr2 incr1

Full Usage: isMultipleOf incr2 incr1

Parameters:
Returns: bool True if incr1 is a multiple of incr2

Check if incr1 is a multiple of incr2

incr2 : Increment

The second increment

incr1 : Increment

The first increment

Returns: bool

True if incr1 is a multiple of incr2

map f arg2

Full Usage: map f arg2

Parameters:
Returns: Increment A new Increment

Maps a function over the ValueUnit of Increment.

f : ValueUnit -> ValueUnit

The function to map

arg1 : Increment
Returns: Increment

A new Increment

minElement

Full Usage: minElement

Returns: Increment -> ValueUnit option The smallest increment value as a ValueUnit option.

Get the smallest increment value

Returns: Increment -> ValueUnit option

The smallest increment value as a ValueUnit option.

restrict newIncr oldIncr

Full Usage: restrict newIncr oldIncr

Parameters:
Returns: Increment The restricted increment: the least common multiple of every pair of a new and an old increment value, without the values that are a multiple of another. The values on both increments lie on these least common multiples.

Restrict an oldIncr with a newIncr.

newIncr : Increment

The new increment

oldIncr : Increment

The old increment

Returns: Increment

The restricted increment: the least common multiple of every pair of a new and an old increment value, without the values that are a multiple of another. The values on both increments lie on these least common multiples.

Example

 let oldIncr = Increment.create ( [| 3N; 5N |] |> ValueUnit.create Units.Mass.gram)
 let newIncr = Increment.create ( [| 2N; 3N |] |> ValueUnit.create Units.Mass.gram)
 Increment.restrict newIncr oldIncr
 // the pairs give 6, 3, 10 and 15; without the multiples of 3 this
 // returns Increment (ValueUnit ([|3N; 10N|], Mass (Gram 1N)))
val oldIncr: obj
val newIncr: obj

toList arg1

Full Usage: toList arg1

Parameters:
Returns: BigRational list

Get the increment as a list of BigRationals

arg0 : Increment
Returns: BigRational list

toString exact arg2

Full Usage: toString exact arg2

Parameters:
    exact : bool - Print exact or not
    arg1 : Increment

Returns: string

Get the string representation of an Increment.

exact : bool

Print exact or not

arg1 : Increment
Returns: string

toValueUnit arg1

Full Usage: toValueUnit arg1

Parameters:
Returns: ValueUnit

Convert an Increment to a ValueUnit.

arg0 : Increment
Returns: ValueUnit

Type something to start searching.