Solid package

Submodules

Solid.EvolutionaryAlgorithm module

class Solid.EvolutionaryAlgorithm.EvolutionaryAlgorithm(crossover_rate, mutation_rate, max_steps, max_fitness=None)[source]

Bases: object

Conducts evolutionary algorithm

best_fitness = None
best_member = None
crossover_rate = None
cur_steps = None
fitnesses = None
max_fitness = None
max_steps = None
mutation_rate = None
population = None
run(verbose=True)[source]

Conducts evolutionary algorithm

Parameters:verbose – indicates whether or not to print progress regularly
Returns:best state and best objective function value
Solid.EvolutionaryAlgorithm.random() → x in the interval [0, 1).

Solid.GeneticAlgorithm module

class Solid.GeneticAlgorithm.GeneticAlgorithm(crossover_rate, mutation_rate, max_steps, max_fitness=None)[source]

Bases: object

Conducts genetic algorithm

best_fitness = None
best_member = None
crossover_rate = None
cur_steps = None
fitnesses = None
max_fitness = None
max_steps = None
mutation_rate = None
population = None
run(verbose=True)[source]

Conducts genetic algorithm

Parameters:verbose – indicates whether or not to print progress regularly
Returns:best state and best objective function value
Solid.GeneticAlgorithm.random() → x in the interval [0, 1).

Solid.HarmonySearch module

class Solid.HarmonySearch.HarmonySearch(hms, hmcr, par, fw, max_steps, max_score=None)[source]

Bases: object

Conducts harmony search

best = None
cur_steps = None
fw = None
hmcr = None
hms = None
max_score = None
max_steps = None
memory = None
par = None
run(verbose=True)[source]

Conducts harmony search

Parameters:verbose – indicates whether or not to print progress regularly
Returns:best state and objective function value of best state
scores = None
Solid.HarmonySearch.random() → x in the interval [0, 1).

Solid.ParticleSwarm module

class Solid.ParticleSwarm.ParticleSwarm(swarm_size, member_size, lower_bound, upper_bound, c1, c2, c3, max_steps, min_objective=None)[source]

Bases: object

Conducts particle swarm optimization

best = None
c1 = None
c2 = None
c3 = None
cur_steps = None
global_best = None
lower_bound = None
max_steps = None
member_size = None
min_objective = None
pos = None
run(verbose=True)[source]

Conducts particle swarm optimization

Parameters:verbose – indicates whether or not to print progress regularly
Returns:best member of swarm and objective function value of best member of swarm
scores = None
swarm_size = None
upper_bound = None
vel = None
Solid.ParticleSwarm.random() → x in the interval [0, 1).
Solid.ParticleSwarm.uniform(low=0.0, high=1.0, size=None)

Draw samples from a uniform distribution.

Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high). In other words, any value within the given interval is equally likely to be drawn by uniform.

low : float or array_like of floats, optional
Lower boundary of the output interval. All values generated will be greater than or equal to low. The default value is 0.
high : float or array_like of floats
Upper boundary of the output interval. All values generated will be less than high. The default value is 1.0.
size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if low and high are both scalars. Otherwise, np.broadcast(low, high).size samples are drawn.
out : ndarray or scalar
Drawn samples from the parameterized uniform distribution.

randint : Discrete uniform distribution, yielding integers. random_integers : Discrete uniform distribution over the closed

interval [low, high].

random_sample : Floats uniformly distributed over [0, 1). random : Alias for random_sample. rand : Convenience function that accepts dimensions as input, e.g.,

rand(2,2) would generate a 2-by-2 array of floats, uniformly distributed over [0, 1).

The probability density function of the uniform distribution is

anywhere within the interval [a, b), and zero elsewhere.

When high == low, values of low will be returned. If high < low, the results are officially undefined and may eventually raise an error, i.e. do not rely on this function to behave when passed arguments satisfying that inequality condition.

Draw samples from the distribution:

>>> s = np.random.uniform(-1,0,1000)

All values are within the given interval:

>>> np.all(s >= -1)
True
>>> np.all(s < 0)
True

Display the histogram of the samples, along with the probability density function:

>>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, 15, normed=True)
>>> plt.plot(bins, np.ones_like(bins), linewidth=2, color='r')
>>> plt.show()

Solid.SimulatedAnnealing module

class Solid.SimulatedAnnealing.SimulatedAnnealing(initial_state, temp_begin, schedule_constant, max_steps, min_energy=None, schedule=’exponential’)[source]

Bases: object

Conducts simulated annealing algorithm

adjust_temp = None
best_energy = None
best_state = None
cur_steps = 0
current_energy = None
current_state = None
current_temp = None
initial_state = None
max_steps = None
min_energy = None
run(verbose=True)[source]

Conducts simulated annealing

Parameters:verbose – indicates whether or not to print progress regularly
Returns:best state and best energy
start_temp = None
Solid.SimulatedAnnealing.random() → x in the interval [0, 1).

Solid.StochasticHillClimb module

class Solid.StochasticHillClimb.StochasticHillClimb(initial_state, temp, max_steps, max_objective=None)[source]

Bases: object

Conducts stochastic hill climb

best_objective = None
best_state = None
cur_steps = 0
current_state = None
initial_state = None
max_objective = None
max_steps = None
run(verbose=True)[source]

Conducts hill climb

Parameters:verbose – indicates whether or not to print progress regularly
Returns:best state and best objective function value
temp = None
Solid.StochasticHillClimb.random() → x in the interval [0, 1).

Solid.TabuSearch module

class Solid.TabuSearch.TabuSearch(initial_state, tabu_size, max_steps, max_score=None)[source]

Bases: object

Conducts tabu search

best = None
cur_steps = None
current = None
initial_state = None
max_score = None
max_steps = None
run(verbose=True)[source]

Conducts tabu search

Parameters:verbose – indicates whether or not to print progress regularly
Returns:best state and objective function value of best state
tabu_list = None
tabu_size = None
Solid.TabuSearch.random() → x in the interval [0, 1).

Module contents