# Functions

## General Functions

AbstractLogic.checkfeasibleFunction
checkfeasible(command::String, logicset::LogicalCombo; verbose=true, all=false, countany=false)

Is called when the user would like to check if a command produces a valid result, possible result, or invalid result. The result is returned as a decimal from 0.0 to 1.0. With 0.0 being no matches and 1.0 being all matches.

Arguments

• verbose : controls print
• countall : all sets have to be feasible or return 0
• countany : any set can be non-zero to return 1

Examples

julia> myset = logicalparse("a, b, c ∈ red, blue, green")
a, b, c ∈ red, blue, green       feasible outcomes 27 ✓          :red blue blue

julia> myset = logicalparse("a != b,c; b = c ==> a = 'blue'", myset)
a != b,c                 feasible outcomes 12 ✓          :green blue blue
b = c ==> a = 'blue'     feasible outcomes 8 ✓           :blue green green

julia> checkfeasible("a = 'green' ==> b = 'red'", myset)
Check: a = 'green' ==> b = 'red' ... a = 'green' ==> b = 'red'   feasible outcomes 17 ✓          :blue red green
possible,  17 out of 21 possible combinations 'true'.
AbstractLogic.LogicalComboType
LogicalCombo <: Any

A LogicalCombo stores the variable names, domains, as well as an binary representation of feasible values given constraints.

Fields

• keys : Stores the names of variables.
• domain : Stores the range of possible matches variables can have.
• logical : A binary vector marking feasibility of length equal to every possible combination of value which the matrix could take on.
• commandlist : An array collection of the strings input to generate the current state of the the object.

Indexing

• [x,y] Where x is numeric or : and y is numeric, colon, or symbol will return matrix point values regardless of feasibility.
• [:,:] Will collect the entire possible domain and is the same as collect().
• [x,0] Will return the logical vector values
• [x,:,true] Will return the xth feasible value of the LogicalCombo set.
• [x,:,false] Will return the xth infeasible value of the LogicalCombo set.
AbstractLogic.logicalparseFunction
logicalparse

Takes a command and parses it into logical calls that either assigning additional feasible variable ranges or constrain the relationship between variables.

logicalparse(command::String; logicset::LogicalCombo = LogicalCombo(), verbose=true)
logicalparse(command::String, logicset::LogicalCombo; ...)
logicalparse(commands::Array{String,1}, logicset::LogicalCombo; ...)
logicalparse(commands::Array{String,1}; ...)

Arguments

• verbose : specifies to print to screen or not

Operators

There are numerous operators available to be used in the logical parse command.

Examples

julia> myset = logicalparse("a, b, c in 1:3")
a,b,c in 1:3             feasible outcomes 27 ✓          :3 3 3

julia> myset = logicalparse("a == b", myset)
a == b                   feasible outcomes 9 ✓           :1 1 2

julia> myset = logicalparse("a > c", myset)
a > c                    feasible outcomes 3 ✓           :3 3 1

julia> myset = logicalparse("c != 1", myset)
c != 1                   feasible outcomes 1 ✓✓          :3 3 2
Missing docstring.

Missing docstring for logicalrepl. Check Documenter's build log for details.

AbstractLogic.searchFunction
search(command::String, logicset::LogicalCombo; verbose=true)

Searches for a possible match among a LogicalCombo in which the wildcard term is true. Search requires the use of a wildcard. In the event that a wildcard is missing, search will insert a {{i}} to the left of the command.{{i+1}} can be used to search for relationships between the ith column and another column.

Examples

julia> myset = logicalparse("v1, v2, v3 ∈ 1:10")
v1, v2, v3 ∈ 1:10        feasible outcomes 1000 ✓        :6 6 10

julia> myset = logicalparse("{{i}} >> {{i+1}}", myset)
{{i}} >> {{i+1}}
>>> v1 >> v2
>>> v2 >> v3
feasible outcomes 56 ✓          :10 7 3

julia> search("{{i}} == 4", myset)
Checking: v1 == 4
Checking: v2 == 4
Checking: v3 == 4

:v1 is a not match with 0 feasible combinations out of 56.
:v2 is a possible match with 10 feasible combinations out of 56.
:v3 is a possible match with 6 feasible combinations out of 56.

julia> search("== 4", myset, verbose=false) == search("{{i}} == 4", myset, verbose=false)
true

julia> search("{{i}} > {{!i}}", myset)
Checking: v1 > v2
Checking: v1 > v3
Checking: v2 > v1
Checking: v2 > v3
Checking: v3 > v1
Checking: v3 > v2

:v1 is a match with 56 feasible combinations out of 56.
:v2 is a not match with 0 feasible combinations out of 56.
:v3 is a not match with 0 feasible combinations out of 56.
AbstractLogic.showfeasibleFunction
showfeasible

Collects a matrix of only feasible outcomes given the parameter space and the constraints. Use collect to output a matrix of all possible matches for parameter space.

Examples

julia> myset = logicalparse("a, b, c in 1:3")
a,b,c in 1:3             feasible outcomes 27 ✓          :3 3 3

julia> myset = logicalparse("a == b; c > b", myset)
a == b                   feasible outcomes 9 ✓           :1 1 3
c > b                    feasible outcomes 3 ✓           :2 2 3

julia> showfeasible(myset)
3×3 Array{Int64,2}:
1  1  2
1  1  3
2  2  3