Equation#

Constructor#

Initialize a new Equation instance.

Constructor of the Equation class#

Argument

Type

Description

Required

Default

container

Container

A reference to the Container object that the symbol is being added to

Yes

name

string

Name of symbol

Yes

type

string

Type of equation being created [eq (or E/e), geq (or G/g), leq (or L/l), nonbinding (or N/n), external (or X/x)]

No

free

domain

list, vector

List, vector of domains given either as a string ("*" for universe set ) or as a reference to a Set object, an empty domain list will create a scalar equation

No

NULL

records

many

Symbol records

No

NULL

domainForwarding

logical

Flag or a vector of flags that forces equation elements to be recursively included in corresponding parent sets (i.e., implicit set definition )

No

FALSE

description

string

Description of symbol

No

“”

Fields#

Fields of the Equation class#

Field

Description

Type

container

reference to the Container that the symbol belongs to

Container

defaultValues

default values for the symbol

numeric (named vector)

description

description of symbol

string

dimension

dimension of symbol, setting dimension is a shorthand notation to set domain to a list of size n containing”*”

integer

domain

list of domains given either as string (* for universe set) or as reference to the Set/Alias object

list

domainForwarding

Flag or a vector of flags that forces equation elements to be recursively included in corresponding parent sets (i.e., implicit set definition )

logical

domainLabels

column headings for the records data frame

list of string

domainNames

string version of domain names

list of string

domainType

none, relaxed or regular depending on state of domain links

string

isScalar

TRUE if self$dimension = 0

logical

name

name of symbol

string

numberRecords

number of symbol records (i.e., returns nrow(self$records) if not NULL)

integer

records

the main symbol records

data frame

shape

a vector describing the array dimensions if records were converted with $toDense()

vector

summary

output a list of only the metadata

list

type

string type of equation

list

Methods#

Methods of the Equation class#

Method

Description

Arguments/Defaults

Returns

addUELs

adds UELs to the symbol

uels (character), dimension=NULL

NULL

copy

copies the symbol to the destination container. overwrite=TRUE overwrites the symbol with the same name in destination. Symbol domains are relaxed if destination Container does not contain equivalent domain sets

destination (Container), overwrite=FALSE

NULL

countDomainViolations

returns the number of domain violations for the symbol

numeric

countDuplicateRecords

returns the number of duplicate records for the symbol

numeric

countEps

total number of SpecialValues$EPS across all columns

columns ="level"

integer

countNA

total number of SpecialValues[["NA"]] across all columns

columns ="level"

integer

countNegInf

total number of SpecialValues$NEGINF across all columns

columns ="level"

integer

countPosInf

total number of SpecialValues$POSINF across all columns

columns ="level"

integer

countUndef

total number of SpecialValues$UNDEF across all columns

columns ="level"

integer

dropDomainViolations

drops domain violations for the symbol

dropDuplicateRecords

drops duplicate records for the Symbol. keep ="first" (drops all duplicates while keeping the first instance as unique), keep="last" (drops all duplicates while keeping the last instance as unique), or keep=FALSE (drops all duplicates)

keep ="first"

equals

Check if two Symbol objects are equal

other (Symbol), columns=NULL (character) (if NULL all columns are compared), checkUELs=TRUE, checkMetaData=TRUE, rtol=0 (relative tolernace), atol=0 (absolute tolerance), verbose=FALSE

logical

findDomainViolations

get a view of records data frame that contain any domain violations

data.frame

findDuplicateRecords

get a view of records data frame that contain duplicate records. keep ="first" (finds all duplicates while keeping the first instance as unique), keep="last" (finds all duplicates while keeping the last instance as unique), or keep=FALSE (finds all duplicates)

keep='first'

data.frame

generateRecords

convenience method to set standard data.frame formatted records. Will generate records with the Cartesian product of all domain sets. The density argument can take any value on the interval [0,1].  If density is < 1, then randomly selected records will be removed. density will accept a numeric of length 1 or dimension. This allows users to specify a density per symbol dimension (when vector) or the density of records dataframe. Random numbers can be generated by passing a user-defined function func(size) to func argument (runif() by default). Random number state can be set with seed argument.

density=1.0 (numeric) func=runif() (named list of functions, function, NULL) seed=NULL (integer)

NULL

getDomainViolations

gets domain violations for the symbol

list of DomainViolation

getMaxValue

get the maximum value across all columns

columns ="level"

numeric

getMaxAbsValue

get the maximum absolute value across all columns

columns ="level"

numeric

getMinValue

get the minimum value iacross all columns

columns ="level"

numeric

getMeanValue

get the mean value across all columns

columns ="level"

numeric

getSparsity

get the sparsity of the symbol w.r.t the size of full cartesian product of the domain sets

numeric

getUELs

returns the UELs used in the Symbol

dimension = NULL, codes = NULL, ignoreUnused=FALSE

character vector

hasDomainViolations

returns TRUE if the symbol contains domain violations, FALSE otherwise

logical

hasDuplicateRecords

returns TRUE if the symbol contains duplicate records, FALSE otherwise

logical

isValid

checks if the symbol is in a valid format, throw exceptions if verbose=TRUE, recheck a symbol if force=TRUE

verbose=FALSE force=FALSE

logical

removeUELs

removes UELs from the symbol

uels=NULL (character), dimension=NULL

NULL

renameUELs

renames UELs in the symbol

uels (character of same length as current UELs or named character vector), dimension=NULL , allowMerge=FALSE (logical). If allowMerge = TRUE, the underlying integer mapping of a factor is allowed to change to offer additional data flexibility

NULL

reorderUELs

reorders UELs in the symbol that appear in the symbol dimensions. If uels is NULL, the UELs are reordered based on symbol records, unused UELs are moved to the end. If dimensions is NULL then reorder UELs in all dimensions of the symbol

uels=NULL (NULL or character of same length as current UELs or named character vector), dimension=NULL (numeric)

NULL

setRecords

main convenience method to set standard data frame records

records (many types)

NULL

setUELs

sets UELs for the Symbol

uels (character), dimension , rename=FALSE

NULL

toDense

convert symbol to a dense matrix or array format

column ="value"

array or matrix

whereMax

find the row number in records data frame with a maximum value (return the first instance only)

column="level"

integer

whereMaxAbs

find the row number in records data frame with a maximum absolute value (return the first instance only)

column="level"

integer

whereMin

find the row number in records data frame with a minimum value (return the first instance only)

column="level"

integer