goulib.optim

various optimization algorithms : knapsack, traveling salesman, simulated annealing, differential evolution

Functions

P(prev_score, next_score, temperature)

anneal(init_function, move_operator, ...)

first_fit_decreasing(items, bins[, maxbins])

fit items in bins using the "first fit decreasing" method :param items: iterable of items :param bins: iterable of Bin s.

hillclimb(init_function, move_operator, ...)

hillclimb until either max_evaluations is reached or we are at a local optima

hillclimb_and_restart(init_function, ...)

repeatedly hillclimb until max_evaluations is reached

kirkpatrick_cooling(start_temp, alpha)

nelder_mead(f, x_start[, step, ...])

Pure Python implementation of the Nelder-Mead algorithm.

reversed_sections(tour)

generator to return all possible variations where the section between two cities are swapped

swapped_cities(tour)

generator to create all possible variations where two cities have been swapped

tour_length(points, dist[, tour])

generator of point-to-point distances along a tour

tsp(points, dist[, max_iterations, ...])

Traveling Salesman Problem @see http://en.wikipedia.org/wiki/Travelling_salesman_problem @param points : iterable containing all points @param dist : function returning the distance between 2 points : def dist(a,b): @param max_iterations :max number of optimization steps @param start_temp, alpha : params for the simulated annealing algorithm.

Classes

BinDict(capacity[, f])

a container with a limited capacity :param capacity: int,float,tuple of whatever defines the capacity of the Bin :param f: function f(x) returning the capacity used by item x.

BinList(capacity[, f])

a container with a limited capacity :param capacity: int,float,tuple of whatever defines the capacity of the Bin :param f: function f(x) returning the capacity used by item x.

DifferentialEvolution(evaluator[, ...])

This is a python implementation of differential evolution taken from http://cci.lbl.gov/cctbx_sources/scitbx/differential_evolution.py

ObjectiveFunction(objective_function)

class to wrap an objective function and keep track of the best solution evaluated

_Bin(capacity[, f])

a container with a limited capacity :param capacity: int,float,tuple of whatever defines the capacity of the Bin :param f: function f(x) returning the capacity used by item x.