A Model is an object that can be run. It is generally used to define algorithms or process.
A model has inputs, outputs and an internal state. Inputs and outputs are used to allow communication between environnement and models and between models. Internal state is used by the model itself but cannot be reached from outside. This internal step is generally used when user want to execute model step by step, each step depending on previous one.
To define model instructions, you need to define at least "step" instructions. To do that, you can use:
To use a Model, you also need to define set_code method that is able to extract inputs, outpus and step, init, ... from given source code.
Animate notification are not yet implemented.
To reset internal state, use init() method. To run one step, use step() method.
Two convenience methods, see run() and "call" can be used to reset internal state and run a given number of step (one by default)
By default, functions are generated for "init", "run" and "animate"
extract and set inputs, outputs and functions from code. For example, if "code" is:
'''
input = a, b:int=5
output = c
'''
def step():
c = a+b
you can extract input, output and step function. So, m = Model("m1") m.set_code(code)
is equivalent to
m = Model("m1") m.set_func_code("step", "c=a+b") m.inputs_info = [InputObj('a'), InputObj('b:int=5')] m.outputs_info = [OutputObj('c')]
Parameters: |
|
---|
Get outputs from namespace and set them inside self.outputs
Parameters: | namespace -- dict where the model will search the outputs |
---|
A Model is an object that can be run. It is generally used to define algorithms or process.
A model has inputs, outputs and an internal state. Inputs and outputs are used to allow communication between environnement and models and between models. Internal state is used by the model itself but cannot be reached from outside. This internal step is generally used when user want to execute model step by step, each step depending on previous one.
To define model instructions, you need to define at least "step" instructions. To do that, you can use:
To use a Model, you also need to define set_code method that is able to extract inputs, outpus and step, init, ... from given source code.
Animate notification are not yet implemented.
To reset internal state, use init() method. To run one step, use step() method.
Two convenience methods, see run() and "call" can be used to reset internal state and run a given number of step (one by default)
By default, functions are generated for "init", "run" and "animate"