Model
- class iesopt.Model(filename: str | Path, **kwargs)[source]
An IESopt model, based on an
IESopt.jl
core model.- compute_iis(filename=None) None [source]
Compute and print the Irreducible Infeasible Set (IIS) of the model, or optionally write it to a file.
Note that this requires a solver that supports IIS computation.
- Parameters:
filename (Optional[str | Path]) – The filename to write the IIS to. If None, the IIS is only printed to the console.
Examples
- property data
Access the IESopt data object of the model.
This is deprecated; use model.internal instead (similar to the Julia usage IESopt.internal(model)).
- extract_result(component: str, field: str, mode: str = 'value')[source]
Manually extract a specific result from the model.
- get_components(tagged=None)[source]
Get all components of the model, possibly filtered by (a) tag(s).
- get_constraint(component: str, constraint: str)[source]
Get a specific constraint from a core component.
- nvar(var: str)[source]
Extract a named variable, from model.
If your variable is called :myvar, and you would access it in Julia using model[:myvar], you can call model.nvar(“myvar”).
- property objective_value: float
Get the objective value of the model. Only available if the model was solved beforehand.
- property results: Results
Get the results of the model.
- property status: ModelStatus
Get the current status of this model. See ModelStatus for possible values.
- write_to_file(filename=None, *, format: str = 'automatic') str [source]
Write the model to a file.
Consult the Julia version of this function, [IESopt.write_to_file](https://ait-energy.github.io/iesopt/pages/manual/julia/index.html#write-to-file) for more information. This will automatically invoke generate if the model has not been generated yet.
- Parameters:
filename (Optional[str]) – The filename to write to. If None, the path and name are automatically determined by IESopt.
- Keyword Arguments:
format (str) – The format to write the file in. If automatic, the format is determined based on the extension of the filename. Otherwise, it used as input to [JuMP.write_to_file](https://jump.dev/JuMP.jl/stable/api/JuMP/#write_to_file), by converting to uppercase and prefixing it with MOI.FileFormats.FORMAT_. Writing to, e.g., an LP file can be done by setting format=”lp” or format=”LP”.
- Returns:
The filename (including path) of the written file.
- Return type:
Examples
import iesopt cfg = iesopt.make_example("01_basic_single_node", dst_dir="opt") # Model will be automatically generated when calling `write_to_file`: model = iesopt.Model(cfg) model.write_to_file() # It also works with already optimized models: model = iesopt.run(cfg) model.write_to_file("opt/out/my_problem.LP") # And supports different formats: target = model.write_to_file("opt/out/my_problem.foo", format="mof") print(target)
- class iesopt.model.ModelStatus[source]
Status of an
iesopt.Model
.