Package transsys :: Module optim :: Class GradientOptimiser
[hide private]
[frames] | no frames]

Class GradientOptimiser

source code

       object --+    
                |    
AbstractOptimiser --+
                    |
                   GradientOptimiser

Gradient descent optimiser.

This optimiser operates by iterating these steps until a termination criterion is reached:

  1. Generate variants of the current state by adding or subtracting delta to each component (unless eliminateFlatComponents is set, see below) while keeping the remainding components fixed, and use these samples to estimate the local gradient.
  2. Construct a new state by adding stepsize * the normalised gradient to the current state.
  3. If the new state improves the objective function, accept it. Then try whether performing a step of stepsize / stepsize_shrink yields further improvement. If so, let stepsize = stepsize / stepsize_shrink and iteratively continue doing so until no further improvement is attained or stepsize exceeds stepsize_max.

    If the new state does not improve the objective function, iteratively let stepsize = stepsize * stepsize_shrink until improvement occurs or stepsize falls below termination_stepsize.

  4. Terminate if stepsize has fallen below termination_stepsize, if the improvement attained was below termination_improvement or the relative improvement fell below the termination_relative_improvement threshold, or if the gradient is flat (i.e. all components are 0), otherwise start next cycle.
Instance Methods [hide private]
 
__init__(self, initial_stepsize=1.0, delta=1.0e-6, stepsize_shrink=0.5, termination_stepsize=1.0e-30, termination_objective=None, termination_iteration=None, termination_numEvaluations=None, termination_improvement=None, termination_relative_improvement=None, stepsize_max=1.0e30, rng=None, transformer=None, randomInitRange=None, verbose=0)
Partial constructor method.
source code
 
check_savefile_magic(self, s)
Check whether s is the "magic word" indicating the beginning of a valid save file.
source code
 
parse_variables(self, f)
Get the values of instance variables from file f.
source code
 
__str__(self)
str(x)
source code
bool
terminationCondition(self, stepsize, objective, improvement, iteration, numEvaluations, gradient)
Check whether termination condition is satisfied.
source code
 
optimise(self, transsys_program, objective_function, factor_name_list=None, gene_name_list=None)
Abstract optimise method.
source code

Inherited from AbstractOptimiser: initialiseParameterTransformer, parse, setRandomNumberGenerator, setRandomNumberSeed

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Class Variables [hide private]
  savefile_magic = 'GradientOptimiser-0.1.1'
Instance Variables [hide private]
  delta
offset from current point in search space used for gradient computation (estimation)
  eliminateFlatComponents
whether components for which the partial derivative was 0 once should be excluded from subsequent optimisation iterations.
  initial_stepsize
distance initially stepped in gradient direction.
  stepsize_max
maximal stepsize, adaptation will not make stepsize exceed this limit
  stepsize_shrink
factor by which stepsize is multiplied / divided in stepsize adaptation
  termination_improvement
optimisation terminates if improvement drops below this threshold.
  termination_iteration
optimisation terminates at this iteration
  termination_numEvaluations
optimisation terminates if number of objective function evaluations reaches or exceeds this
  termination_objective
optimisation terminates if objective function value falls to or below this
  termination_relative_improvement
optimisation terminates if relative improvement drops below this threshold.
  termination_stepsize
minimal stepsize, optimisation terminates if stepsize falls below this limit
  transformer
parameter transformer
  verbose
controls verbosity (of optimisation process)

Inherited from AbstractOptimiser: randomInitRange, rng

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, initial_stepsize=1.0, delta=1.0e-6, stepsize_shrink=0.5, termination_stepsize=1.0e-30, termination_objective=None, termination_iteration=None, termination_numEvaluations=None, termination_improvement=None, termination_relative_improvement=None, stepsize_max=1.0e30, rng=None, transformer=None, randomInitRange=None, verbose=0)
(Constructor)

source code 

Partial constructor method.

This constructor is to be invoked from subclass constructors. Instances of AbstractOptimiser do not have any use.

If the rng parameter is None (the default), the constructor initialises the rng instance variable to random.Random(1).

Parameters:
  • initial_stepsize - distance initially stepped in gradient direction. Subject to subsequent adaptation
  • delta - offset from current point in search space used for gradient computation (estimation)
  • stepsize_shrink - factor by which stepsize is multiplied / divided in stepsize adaptation
  • termination_stepsize - minimal stepsize, optimisation terminates if stepsize falls below this limit
  • termination_objective - optimisation terminates if objective function value falls to or below this
  • termination_iteration - optimisation terminates at this iteration
  • termination_numEvaluations - optimisation terminates if number of objective function evaluations reaches or exceeds this
  • termination_improvement - optimisation terminates if improvement drops below this threshold.
  • termination_relative_improvement - optimisation terminates if relative improvement drops below this threshold.
  • stepsize_max - maximal stepsize, adaptation will not make stepsize exceed this limit
  • transformer - parameter transformer
Overrides: object.__init__

check_savefile_magic(self, s)

source code 

Check whether s is the "magic word" indicating the beginning of a valid save file.

Overrides: AbstractOptimiser.check_savefile_magic

parse_variables(self, f)

source code 

Get the values of instance variables from file f.

Overrides: AbstractOptimiser.parse_variables

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

terminationCondition(self, stepsize, objective, improvement, iteration, numEvaluations, gradient)

source code 

Check whether termination condition is satisfied.

Returns: bool
True if termination condition is satisfied

optimise(self, transsys_program, objective_function, factor_name_list=None, gene_name_list=None)

source code 

Abstract optimise method.

Subclasses of AbstractOptimiser must override this method and conform to the parameter signature specified by this abstract method in doing so. Implementations of the optimise method may take additional parameters, which must have suitable defaults so a call with just the two parameters defined here remains valid. It is generally preferable to provide such parameters through instance variables.

Parameters:
  • transsys_program_init - The transsys program to be optimised. Optimisers should not modify this transsys program, modifications should be done to a copy.
  • objective_function - The objective function used to optimise the transsys program.
  • factor_name_list - factors for which parameters are to be optimised
  • gene_name_list - genes for which parameters are to be optimised
Overrides: AbstractOptimiser.optimise
(inherited documentation)

Instance Variable Details [hide private]

eliminateFlatComponents

whether components for which the partial derivative was 0 once should be excluded from subsequent optimisation iterations. This effectively freezes a component once its partial derivative becomes "flat", thus speeding up subsequent iterations but incurring the risk of freezing in a suboptimal state.

initial_stepsize

distance initially stepped in gradient direction. Subject to subsequent adaptation