The get_optimizer_model function#

Aliases#

halerium.core.get_optimizer_model
halerium.core.model.get_optimizer_model
get_optimizer_model(graph, adjustables, cost_function, reduce_dynamic_cost=<class 'halerium.core.operator.operators.Sum'>, data=None, method='ForwardOptimizer', compiler=None, return_solved=True, copy_graph=True, model_graph_options=None, solver_args=None, **kwargs)#

Get optimizer model.

Returns an optimizer model instance suitable for optimizations.

Parameters:
  • graph (halerium.core.Graph) – A Graph instance.

  • adjustables (list-like) – list of variables to tune to optimize model.

  • cost_function (callable) – a function taking the graph as argument and returning an operator whose value is the objective function to minimize

  • reduce_dynamic_cost (callable) – the function to apply to dynamic costs to reduce to a scalar

  • data (dict, halerium.core.DataLinker, optional) – The input data for the prediction. Either dictionary with variables as keys and data arrays as values, or a DataLinker holding links to the variables in graph. The default is None.

  • method ({'Forward'}, optional) – The solving method. According to the chosen method a ForwardModel instance is created. See the corresponding model class for further information. The default is ‘Forward’.

  • compiler (optional) – The compiler instance or class for compiling the model. The default is None, in which case a Tensorflow compiler is used.

  • return_solved (bool, optional) – Whether to return the model in a solved state. The default is True.

  • copy_graph (bool, optional) – Whether the model should make a copy of the graph for its own use, or just keep the graph itself as attribute. Users should leave this set to the default True, unless they are certain that the graph won’t be altered by the user or other code. Such changes to a graph a model holds directly (i.e. not a copy) makes that model inconsistent and likely causes errors.

  • model_graph_options (dict, optional) – The options for creating the model graph. The default is None.

  • solver_args (dict, optional) – The arguments to pass to the model’s solver function. The default is None.

  • **kwargs (model arguments, optional) – Further arguments that depend on the specified method. See the corresponding model classes for further information.

Raises:

ValueError – If the supplied method is unknown an error is raised.

Returns:

model – An instance of the model class specified by method created with the provided graph and data_linker.

Return type:

halerium.core.model.model.Model