Working With Gana#

Gana is a general purpose algebraic modeling language (AML) that Energia uses for generating Mathematical Programs. For more information refer to Gana’s documentation.

Element Sets and Counters#

All of these can be accessed directly from the Model

from energia import Model
m = Model()
m.program_attrs
['constraint',
 'function',
 'variable',
 'parameter',
 'theta',
 'constraints',
 'constraint_sets',
 'functions',
 'function_sets',
 'variables',
 'variable_sets',
 'parameters',
 'parameter_sets',
 'thetas',
 'theta_sets',
 'solution',
 'formulation',
 'evaluation',
 'n_constraint',
 'n_function',
 'n_variable',
 'n_parameter',
 'n_theta',
 'n_constraints',
 'n_constraint_sets',
 'n_functions',
 'n_function_sets',
 'n_variables',
 'n_variable_sets',
 'n_parameters',
 'n_parameter_sets',
 'n_thetas',
 'n_theta_sets',
 'n_solution',
 'n_formulation',
 'n_evaluation',
 'index_sets',
 'indices',
 'objectives',
 'parameter_sets',
 'X']

Prg Matrices and Other Properties#

Some Prg properties can also be called, such as all the keys with the values Program(m) These include all the matrices necessary to gain a full understanding of the system

m.properties
{'A': Program(m),
 'B': Program(m),
 'C': Program(m),
 'F': Program(m),
 'G': Program(m),
 'H': Program(m),
 'CrA': Program(m),
 'CrB': Program(m),
 'NN': Program(m),
 'A_with_NN': Program(m),
 'B_with_NN': Program(m),
 'Z': Program(m),
 'P': Program(m)}

Exporting to Other Formats#

The mathematical program can be accessed using the program or _ attributes

energia.Program inherit from gana.Prg, and can be exported as:

function

output format

.ppopt()

ppopt.MPLP_Program

.gurobi()

gurobipy.Model

.mps()

.mps file

.lp()

.lp file

The following Prg attributes can be called from the model