Skip to contents

Abstract Syntax Tree (AST) classes

Data structures to represent mathematical expressions.

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

Multimod classes

Classes to represent a model with sets, parameters, variables, equations, and data.

set_multimod_python() get_multimod_python() set_multimod_julia() get_multimod_julia() set_multimod_glpsol() get_multimod_glpsol() set_multimod_solver() get_multimod_solver() multimod_config_write() multimod_config_read() multimod_config_path() multimod_config_show()
Configuration management for multimod solver paths
new_ast() ast_set()
Create a new multimod AST (Abstract Syntax Tree) node
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

Generic methods

Generic methods for multimod classes.

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
show_bounds_mapping()
Show bounds parameter mapping
show_unmatched()
Show unmatched elements
as.character(<expression>)
Convert AST expression to character

LaTeX functions

Functions to convert multimod objects to LaTeX.

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

Functions to read GAMS models and convert multimod objects to GAMS code.

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

Functions to read GMPL models and convert multimod objects to GMPL code.

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(<model>)
Write a full GMPL model file from a multimod object
write_gmpl()
Write a GMPL/MathProg model file from a multimod object
write_gmpl_data()
Write GMPL data file from multimod model
export_glpk_model()
Export GLPK model to MPS or CPLEX LP format
export_data_gmpl()
Generate GMPL code to export all sets and parameters to CSV files
import_gmpl_data()
Import GMPL Data to Model
solve_gmpl()
Solve GMPL model using glpsol command line tool

Functions to read JuMP models and convert multimod objects to JuMP code.

as_jump()
Convert multimod object to Julia/JuMP syntax
write_jump()
Write a Julia/JuMP model file from a multimod object
write_jump_solution_code()
Write JuMP solution values to disk
compare_jump_stats()
Compare JuMP model constraint statistics between two model directories
solve_jump()
Solve a JuMP Model

Functions to convert multimod objects to Pyomo code.

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

Configuration and Environment

Functions for configuring solver paths and Python/Julia environments.

Folding functions

Functions for parameter folding to reduce model size by eliminating redundant dimensions.

create_fold_spec()
Create fold specification for parameters (generic interface)
create_fold_spec_energyRt()
Create fold specification for energyRt models (convenience wrapper)
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 functions

Functions for model trimming to remove unused elements (empty data, unused variables, dead branches).

untrim_model()
Untrim model or specific elements
get_trim_summary()
Get trim summary statistics
is_trimmed()
Check if model or object is trimmed

Model workspace and data management

Functions for saving/loading models and managing model workspaces with multiple data formats.

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
import_energyRt_data()
Import energyRt scenario data into a multimod model
populate_sets_from_scenario()
Populate sets from energyRt scenario
link_scenario_data()
Link energyRt scenario data to model
import_osemosys_data()
Import OSeMOSYS data into multimod model
export_osemosys_to_csv()
Export OSeMOSYS data to CSV files
export_model_source()
Export Model Source Files
add_set_data()
Add data to a set
export_import_log_from_model()
Export import log to CSV

Solver integration

Functions for solving models and loading solutions.

solve_jump()
Solve a JuMP Model
solve_pyomo()
Solve a Pyomo model exported by multimod
solve_glpk()
Solve GLPK model using glpsol command line tool
execute_glpkAPI()
Solve GLPK model using glpkAPI

Model comparison and debugging

Functions for comparing models, solutions, and debugging model generation.

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_lp()
Compare two LP files and report differences
compare_mps()
Compare two MPS files and report differences
compare_solution()
Compare solutions from different solver outputs
compare_variables()
Compare variable solutions between two models

Index aliases and mapping

Functions for managing index aliases and domain extraction.

generate_index_alias()
Generate dummy variable name from set name
generate_index_aliases()
Generate dummy variable names for a list of sets
add_index_aliases()
Add index aliases to a multimod model
has_index_aliases()
Check if model has index aliases
en_extract_domains_from_comments()
Extract energyRt domain mappings from GAMS file comments

Parameter evaluation and analysis

Functions for evaluating parameters and analyzing folding opportunities.

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

AST conversion to R

Functions for converting AST to R code.

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

Data and examples

Example datasets and models.

example_models
Example Models in Multiple Formats

Utility functions

Utility functions for multimod.

validate()
Validate multimod or AST objects
get_active_dims()
Get active dimensions from a parameter
get_data()
Get data from model (with optional lazy loading)
get_data_path()
Get data path for a parameter or mapping
get_energyrt_defvals()
Get default values from energyRt modInp
get_fold_summary()
Get folding statistics summary
get_glpk_model_stats()
Get GLPK model statistics without solving
get_import_log()
Get data import log from model
get_index_alias()
Get index alias for a set
get_lazy_data()
Get lazy data with automatic loading
get_network_data()
Get network data for a multimod equation
get_trim_summary()
Get trim summary statistics
set_multimod_python() get_multimod_python() set_multimod_julia() get_multimod_julia() set_multimod_glpsol() get_multimod_glpsol() set_multimod_solver() get_multimod_solver() multimod_config_write() multimod_config_read() multimod_config_path() multimod_config_show()
Configuration management for multimod solver paths
set_data_path()
Set data path for a parameter or mapping
is_folded()
Check if a parameter or model is folded
is_gams_expression()
Check if a string is a compound expression
is_in_memory()
Data management utilities for multimod models
is_special()
Check if a character is a special character
is_trimmed()
Check if model or object is trimmed
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
parse_gams_equation()
Parse a GAMS equation into an AST object.
format_latex_aligned()
Format a LaTeX equation across multiple lines using aligned
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
extract_where_nodes()
Extract "where" nodes from an AST
alias_ast_names()
Apply name aliases to AST nodes
depth()
Get the depth of a nested list structure (AST, multimod, and other objects)
annotate_brackets()
Annotate expression tree with bracket requirements
brackets_pair()
Get a pair of brackets
wrap_brackets()
Wrap text with brackets
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
resolve_full_name()
Resolve alias to full set name
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

Internal and helper functions

Internal functions and helpers (typically not called directly by users).

load_all_mappings()
Load all mappings into memory
load_all_parameters()
Load all parameters into memory
load_mapping()
Load mapping data into memory
load_model()
Load multimod model from disk
load_osemosys_from_csv()
Load OSeMOSYS data from CSV directory
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
save_model()
Save model data on disk
save_parameter()
Save parameter 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_defvals_from_energyrt()
Update model parameters with default values from energyRt
populate_sets_from_data()
Populate sets from model's own mappings and parameters
populate_sets_from_scenario()
Populate sets from energyRt scenario
register_index_alias()
Read GMPL/MathProg Model File
make_valid()
Make a multimod model valid by reconciling symbols
quick_compare()
Quick comparison showing first few differences
mps_matrix_long()
Extract the sparse constraint matrix of an MPS file
osemosys_dat_to_model()
Convert OSeMOSYS .dat to CSV and import into model
read_osemosys_dat()
Read OSeMOSYS data files
read_csv_results()
Read CSV results from GMPL solver solution directory and save to model variables

visualization

Visualization functions for multimod.

get_network_data()
Get network data for a multimod equation
as_visNetwork()
Convert a multimod ast or equation to a visNetwork object