Previous topic

nvd3

Next topic

piecewise

This Page

optim

optimization algorithms

optim.hillclimb(init_function, move_operator, objective_function, max_evaluations)[source]

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

optim.hillclimb_and_restart(init_function, move_operator, objective_function, max_evaluations)[source]

repeatedly hillclimb until max_evaluations is reached

optim.P(prev_score, next_score, temperature)[source]
class optim.ObjectiveFunction(objective_function)[source]

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

__init__(objective_function)[source]
__call__(solution)[source]
optim.kirkpatrick_cooling(start_temp, alpha)[source]
optim.anneal(init_function, move_operator, objective_function, max_evaluations, start_temp, alpha)[source]
optim.reversed_sections(tour)[source]

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

optim.swapped_cities(tour)[source]

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

optim.tour_length(points, dist, tour=None)[source]

generator of point-to-point distances along a tour

optim.tsp(points, dist, max_iterations=100, start_temp=None, alpha=None, close=True, rand=True)[source]

Travelling 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. if None, hill climbing is used @param close : computes closed TSP. if False, open TSP starting at points[0] @return iterations,score,best : number of iterations used, minimal length found, best path as list of indexes of points