2.1.6.1.1. sf_tools.signal.cost module

COST FUNCTIONS

This module contains classes of different cost functions for optimization.

Author:Samuel Farrens <samuel.farrens@gmail.com>
Version:2.2
Date:23/10/2017
class sf_tools.signal.cost.costObj(costFunc, initial_cost=1000000.0, tolerance=0.0001, cost_interval=1, test_range=4, verbose=True, plot_output=None)[source]

Bases: object

Generic cost function object

This class updates the cost according to the input cost functio class and tests for convergence

Parameters:
  • costFunc (class) – Class for calculating the cost
  • initial_cost (float, optional) – Initial value of the cost (default is “1e6”)
  • tolerance (float, optional) – Tolerance threshold for convergence (default is “1e-4”)
  • cost_interval (int, optional) – Iteration interval to calculate cost (default is “1”)
  • test_range (int, optional) – Number of cost values to be used in test (default is “4”)
  • verbose (bool, optional) – Option for verbose output (default is “True”)
  • plot_output (str, optional) – Output file name for cost function plot

Notes

The costFunc class must contain a method called calc_cost().

_check_cost()[source]

Check cost function

This method tests the cost function for convergence in the specified interval of iterations using the last n (test_range) cost values

Returns:
Return type:bool result of the convergence test
get_cost(*args, **kwargs)[source]

Get cost function

This method calculates the current cost and tests for convergence

Returns:
Return type:bool result of the convergence test
plot_cost()[source]

Plot the cost function

This method plots the cost function as function of iteration number