modelx.cur_model#
- cur_model(model=None)[source]#
Get or set the current model.
When called without arguments, returns the current model. When called with a model argument, sets that model as current and returns it.
The current model is used as the default model for operations like
new_space(),defcells(), and other functions that operate on models.- Parameters:
model (str or
Model, optional) –The model to set as current. Can be:
- Returns:
The current model, or
Noneif no model exists.- Return type:
Modelor None
Example
>>> import modelx as mx >>> >>> m1 = mx.new_model('Model1') >>> m2 = mx.new_model('Model2') >>> >>> # Get current model >>> mx.cur_model() <Model Model2> >>> >>> # Set current model by object >>> mx.cur_model(m1) <Model Model1> >>> >>> # Set current model by name >>> mx.cur_model('Model2') <Model Model2>
See also
new_model(): Create a new modelcur_space(): Get or set current spaceget_models(): Get all models