optimise_statements function

(Shortest import: from brian2.codegen.optimisation import optimise_statements)

brian2.codegen.optimisation.optimise_statements(scalar_statements, vector_statements, variables, blockname='')[source]

Optimise a sequence of scalar and vector statements

Performs the following optimisations:

  1. Constant evaluations (e.g. exp(0) to 1). See evaluate_expr.

  2. Arithmetic simplifications (e.g. 0*x to 0). See ArithmeticSimplifier, collect().

  3. Pulling out loop invariants (e.g. v*exp(-dt/tau) to a=exp(-dt/tau) outside the loop and v*a inside). See Simplifier.

  4. Boolean simplifications (allowing the replacement of expressions with booleans with a sequence of if/thens). See Simplifier.