Skip to contents

Multimod classes

Constructors for the declarations a model is made of, and the text route for writing an equation.

mm_equation()
Write an equation as MathProg, GAMS or JuMP text
new_equation()
Create a multimod equation object
new_mapping()
Create a multimod mapping object
new_model()
Create a multimod model object
new_parameter()
Create a multimod parameter
new_set()
Create a new set object
new_variable()
Create a multimod variable
as_multimod()
Convert an object to a multimod structure

Abstract Syntax Tree (AST) classes

Nodes for expressions, references and index domains.

new_ast() ast_set()
Create a new multimod AST (Abstract Syntax Tree) node
ast_call()
Create a function call AST node
ast_constant()
Create a constant AST node
ast_dims()
Create an AST node for dimensions (dims) of a symbol
ast_equation()
Create an equation AST node
ast_expression()
Create an expression AST node
ast_func()
Create a function AST node
ast_mapping()
Create a mapping AST node
ast_parameter()
Create a parameter AST node
ast_prod()
Create a product AST node
ast_setmax()
Create a set maximum AST node
ast_setmin()
Create a set minimum AST node
ast_shift()
Create an index shift AST node for ordered set references
ast_sum()
Create a summation AST node
ast_symbol()
Create a symbol AST node (for unclassified identifiers)
ast_unary()
Create a unary expression AST node
ast_variable()
Create a variable AST node
ast_when()
Construct a conditional expression node for multimod AST
ast_where()
Create a "where" AST node

Index aliases

Short index names used in rendered equations.

add_index_aliases()
Add index aliases to a multimod model
generate_index_alias()
Generate dummy variable name from set name
generate_index_aliases()
Generate dummy variable names for a list of sets
has_index_aliases()
Check if model has index aliases

Generic methods

Printing, plotting and summarising model objects.

print(<ast_comparison>)
Print comparison results in a readable format
print(<ast_function>)
Print method for functions created from AST
print(<model_validation>)
Print method for model validation results
print(<ast>) print(<func>)
Print methods for AST classes
print(<variable_comparison>)
Print method for variable comparison results
as.character(<expression>)
Convert AST expression to character

Schema and serialization

The node schema, validation, and the JSON round trip.

ast_schema()
The multimod AST schema
schema_type()
Schema node type of an AST node
schema_node_types()
Node types known to the schema
validate_ast()
Validate an AST node or model against the schema
ast_json_schema()
Emit a JSON Schema for the multimod AST
model_to_json()
Serialise a model to JSON
model_from_json()
Rebuild a model from JSON
ast_to_json()
Convert an AST node to a language-neutral list
ast_from_json()
Rebuild an AST node from a language-neutral list
Set() Mapping() Parameter() Variable() Equation() SetRef() MappingRef() ParameterRef() VariableRef() Symbol() Dims() Constant() Expression() Unary() When() Func() Sum() Prod() SetMin() SetMax() Shift() Call() Where()
Constructors under the cross-language names
is_declaration()
Is this node a declaration rather than a reference?

GAMS

Read GAMS, and render a model or any node back to it.

read_gams()
Read GAMS model file and parse its core structure.
parse_equation_header()
Parse a GAMS equation header
parse_gams_equation()
Parse a GAMS equation into an AST object.
remove_ontext_offtext()
Strip GAMS block comments
is_gams_expression()
Check if a string is a compound expression
as_gams()
Convert multimod object to GAMS syntax
write_gams(<mm_model>)
Write a full GAMS model file from a multimod object
write_gams()
Write a GAMS model file from a multimod object

MathProg

Read GNU MathProg, render it, and solve it with the glpsol executable.

read_gmpl()
Read GMPL model file
read_gmpl_data()
Read GMPL data file and parse its contents
read_gmpl_declarations()
Read GMPL declarations sequentially
as_gmpl()
Convert multimod object to GMPL/MathProg syntax
write_gmpl()
Write a GMPL/MathProg model file from a multimod object
write_gmpl_data()
Write GMPL data file from multimod model
solve_gmpl()
Solve GMPL model using glpsol command line tool
solve_glpk()
Solve GLPK model using glpsol command line tool
read_csv_results()
Read CSV results from GMPL solver solution directory and save to model variables
export_data_gmpl()
Generate GMPL code to export all sets and parameters to CSV files
import_gmpl_data()
Import GMPL Data to Model

JuMP

as_jump()
Convert multimod object to Julia/JuMP syntax
write_jump()
Write a JuMP model file from a multimod model
write_jump_solution_code()
Julia source of the JuMP solution writer
solve_jump()
Solve a JuMP Model
parse_jump_equation()
Parse one JuMP constraint into a multimod equation

Pyomo

as_pyomo()
Convert a multimod AST node to Pyomo syntax
write_pyomo()
Write Pyomo model artifacts
solve_pyomo()
Solve a Pyomo model exported by multimod

LaTeX

Publication-ready rendering of equations and whole models.

as_latex()
Convert objects to LaTeX format
write_latex(<mm_equation>)
Write LaTeX representation of an equation
write_latex(<mm_model>)
Write LaTeX representation of a model
write_latex()
Write LaTeX representation of an equation or model
format_latex_aligned()
Format a LaTeX equation across multiple lines using aligned
estimate_latex_length()
Estimate the length of a LaTeX string
latex_math_brakets()
Generate LaTeX brackets for math expressions
latex_top_level_operators()
Identify top-level LaTeX operators in an expression

Folding

Drop dimensions a parameter does not vary over.

fold_model()
Fold model dimensions to reduce data size
create_fold_spec()
Create a fold specification for a model's parameters
analyze_parameter_redundancy()
Analyze parameter redundancy in model
analyze_dimension_redundancy()
Analyze if a dimension can be safely folded
get_fold_summary()
Get folding statistics summary
is_folded()
Check if a parameter or model is folded
get_active_dims()
Get active dimensions from a parameter
unfold_model()
Unfold model to restore original dimensions

Trimming

Drop symbols the model does not use.

trim_model()
Trim a model to the elements its data uses
untrim_model()
Untrim model or specific elements
get_trim_summary()
Get trim summary statistics
is_trimmed()
Check if model or object is trimmed

Matrix route and MPS

Assemble the LP from the AST, write MPS, and solve in R.

model_to_lp()
Assemble a model into LP arrays
build_col_index()
Build the LP column index
build_row_index()
Build the LP row index
build_triplets()
Extract (row, column, coefficient) triplets from a model
check_matrix_numbers()
Report the magnitude spectrum of an assembled LP
mm_session()
Create a solver session
solve_highs()
Solve a model in-process with HiGHS
solve_mps()
Solve a written MPS file locally and emit a HiGHS solution file
write_mps()
Write a model to MPS, with the index tables needed to read results back
read_mps_solution()
Map a solved MPS back onto model symbols
read_highs_solution()
Parse a HiGHS solution file
read_cuopt_solution()
Parse a cuOpt solution file
read_solver_solution()
Read a solution file, whichever solver wrote it
write_solution()
Write a solution as one table per variable
write_energyrt_output()
Write a solution in energyRt's output/ layout

Model workspace and data management

Save, load and update a model and its data.

save_model()
Save model data on disk
load_model()
Load multimod model from disk
get_data()
Get data from model (with optional lazy loading)
update_parameter()
Update parameter data
update_mapping()
Update mapping data
save_parameter()
Save parameter data to disk and free memory
export_model_source()
Export the bundled energyRt model as a solver workspace
add_set_data()
Add data to a set

Configuration and environment

Where the interpreters and solvers are found.

Data and examples

example_models
Example models

Utility functions

Helpers used across the package.

validate()
Validate multimod or AST objects
make_valid()
Make a multimod model valid by reconciling symbols
get_data_path()
Get data path for a parameter or mapping
get_index_alias()
Get index alias for a set
get_lazy_data()
Get lazy data with automatic loading
set_data_path()
Set data path for a parameter or mapping
is_in_memory()
Data management utilities for multimod models
is_special()
Check if a character is a special character
is_trimmed_any()
Check if any elements are actually trimmed
is_word()
Check if a string is a word (alphabetic characters only)
is_word_num()
Check if a string is alphanumeric (letters, digits, or underscores)
validate_fold()
Validate fold integrity
validate_index_aliases()
Validate index_aliases for a model
extract_args(<ast_formula>)
Extract Arguments from ast_formula
extract_args()
Extract Arguments from AST
extract_ast_elements()
Recursively extract elements by name from a nested structure
alias_ast_names()
Apply name aliases to AST nodes
depth()
Get the depth of a nested list structure (AST, multimod, and other objects)
brackets_pair()
Get a pair of brackets
wrap_brackets()
Wrap text with brackets
lp_presolve()
Presolve an assembled LP
map_ast()
Recursively apply a function to all nodes of an AST
node_hash()
Generate a stable hash for an AST or multimod object (excluding internal hash fields)
node_type()
Get the type of an AST or multimod node
remap_ast_elements()
Replace AST elements with "ast_where" nodes
split_at_top_level_operators()
Split LaTeX math string at top-level operators
split_top_level_args()
Split function arguments at the top level
build_symbols_list()
Build a list of symbols from model_info

Experimental

Exported but untested; interfaces may change or be withdrawn.

write_gams_data()
Write a model's data to a GDX for GAMS
as_r()
Convert AST to R Code
as_r(<ast_formula>)
Convert ast_formula to R Code
as_rfunction()
Convert AST to R Function
collect_ast_classes()
Collect all AST node classes from model or AST
compare_ast()
Compare two AST objects and report differences
compare_ast_simple()
Compare AST objects using compare package with custom handling
compare_csv_files()
Compare CSV files in two directories
compare_dataframes()
Compare two dataframes and identify differences
compare_jump_stats()
Compare JuMP model constraint statistics between two model directories
compare_solution()
Compare solutions from different solver outputs
compare_variables()
Compare variable solutions between two models
quick_compare()
Quick comparison showing first few differences
get_network_data()
Get network data for a multimod equation
as_visNetwork()
Convert a multimod ast or equation to a visNetwork object
evaluate_parameters()
Evaluate Parameter Formulas and Defaults
analyze_fold_opportunities()
Analyze fold opportunities without applying
has_ast_formulas()
Check if model has unevaluated AST formulas or defaults
load_all_mappings()
Load all mappings into memory
load_all_parameters()
Load all parameters into memory
load_mapping()
Load mapping data into memory
load_parameter()
Load parameter data into memory
save_all_mappings()
Save all mappings to disk
save_all_parameters()
Save all parameters to disk
save_mapping()
Save mapping data to disk and free memory
log_solution_load()
Log solution loading from solver to variables directory
restore_ast()
Restore AST from preserved copies
populate_sets_from_data()
Populate sets from model's own mappings and parameters
register_index_alias()
Register an index alias for a set