def four_peaks(self, threshold, stateCount):
        initial = FourPeaks(t_pct=threshold)
        state = self.generate_test_state(stateCount, "FP")
        problem = DiscreteOpt(length=stateCount,
                              fitness_fn=initial,
                              maximize=True)
        problem.set_state(state)

        return problem
 def __init__(self, length=10, t_pct=0.1, verbose=False):
     self.problem = 'fourpeaks{l}'.format(l=length)
     self.verbose = verbose
     self.name = 'Four Peaks'
     fitness_fn = FourPeaks(t_pct=t_pct)
     self.problem_fit = DiscreteOpt(length=length,
                                    fitness_fn=fitness_fn,
                                    maximize=True,
                                    max_val=2)
Exemple #3
0
 def test_fourpeaks_r0_max0():
     """Test FourPeaks fitness function for the case where R=0 and max=0"""
     state = np.array([0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1])
     assert FourPeaks(t_pct=0.30).evaluate(state) == 0
Exemple #4
0
 def test_fourpeaks_r_gt0():
     """Test FourPeaks fitness function for the case where R>0 and max>0"""
     state = np.array([1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0])
     assert FourPeaks(t_pct=0.15).evaluate(state) == 16