cost_function

class nrv.optim.cost_function(static_context=None, context_modifier=None, cost_evaluation=None, simulation=None, kwargs_CM={}, kwargs_S={}, kwargs_CE={}, filter=None, saver=None, file_name='cost_saver.csv', **kawrgs)[source]

A class to define cost from position input vector

Parameters:
  • static_context (str | dict) – saving dictionary or saving file name of a nrv_simulable object which should be use as static context of the optimisation

  • context_modifier (funct) –

    function creating a context from a particle position, parameters:
    >>> context_modifier(X: np.ndarray, static_context: NRV_simulable, **kwargs) -> NRV_simulable:
    
    returns

    context : values of a context (array)

  • cost_evaluation (funct) –

    function calculating a cost from a axon simulation results, parameters:
    >>> cost_evaluation(results: sim_results, **kwargs) -> float:
    

  • simulation (funct) – optional

  • kwargs_CM (dict) – key word arguments of context_modifier function, by default {}

  • kwargs_S (dict) – key word arguments of simulate_context function, by default {}

  • kwargs_CE (dict) – key word arguments of cost_evaluation function, by default {}

  • t_sim (float) – time of the simulation on wich the cost will be calculated in ms (ms), by default 100ms

  • dt (float) – simulation time stem for neuron (ms), by default 1us

  • filter (funct or None) – function wich return a filtered postition from a position, if None, position is unfiltered, by default None

  • saver (funct or None) – function added at the end after calculating the cost for personalized savings, if None, nothing will be saved, by default None

Methods

cost_function.__init__([static_context, ...])

Init method for NRV_class

cost_function.get_parameters()

Generic method returning all the atributes of an NRV_class instance

cost_function.get_sim_results(X)

Simulated the static context modified with the tuning paramters X

cost_function.load(data[, blacklist])

Generic loading method for NRV_class instance

cost_function.save([save, fname, blacklist])

Generic saving method for NRV_class instance.

cost_function.set_context_modifier(...)

set the cost context modifier after the instantiation

cost_function.set_cost_evaluation(...)

set the cost evalutation function after the instantiation

cost_function.set_parameters(**kawrgs)

Generic method to set any attribute of NRV_class instance

cost_function.set_static_context(...)

set the cost static_context after the instantiation

cost_function.simulate_context()