def setUp(self):
     self.n = 24
     cookies = coolcookies.\
         makeobjects(self.n, 6, '/Users/gelliebeenz/Documents/Python/ObjectiveMethod/'
                                'TimeDependent/ToyProblem/Cookies24.txt')
     self.moop = mop.MOCookieProblem(self.n, 8, 15, 2, cookies)
     self.bpp = grasp.BPP(self.n, cookies, self.moop)
     # Make stub solution ------------------------------------------------------
     # variable length representation
     vlrep = [[0, 1, 2, 4], [3, 5], [6, 7, 8, 9], [10, 11],
              [12, 13, 14, 15], [16, 17], [18, 19, 20], [21, 22, 23]]
     # t_fill
     tfill = np.zeros(self.n, dtype=np.float)
     tfill_unique = [
         885.0, 722.0, 1507.0, 1428.0, 2210.0, 1958.0, 2764.0, 2509.0
     ]
     for i in range(len(vlrep)):
         tfill[i] = tfill_unique[i]
     # x and y matrices
     y = np.zeros(self.n, dtype=np.int)
     y[:len(vlrep)] = 1
     x = np.zeros((self.n, self.n))
     for i in range(len(vlrep)):
         for j in vlrep[i]:
             x[i, j] = 1
     self.newsol = sols.CookieSol(0, x, y, vlrep, tfill)
     self.newsol = self.bpp.checkandfit(self.newsol)
 def setUp(self):
     cookies = coolcookies.makeobjects(24, 6, 'tests/Cookies24.txt')
     self.moop = mooproblem.MOCookieProblem(24, 8, 15, 2, cookies)
     # Make mock solution --------------------------------------------------
     # variable length representation
     self.vlrep = [[0, 1, 2, 4], [3, 5], [6, 7, 8, 9], [10, 11],
                   [12, 13, 14, 15], [16, 17], [18, 19, 20], [21, 22, 23]]
     # tfill matrix
     self.tfill = np.zeros(24, dtype=np.float)
     tfill_unique = [
         885.0, 722.0, 1507.0, 1428.0, 2210.0, 2958.0, 2764.0, 2809.0
     ]
     for i in range(8):
         self.tfill[i] = tfill_unique[i]
     # x and y matrices
     self.y = np.zeros(24, dtype=np.int)
     self.y[:len(self.vlrep)] = 1
     self.x1 = np.zeros((24, 24), dtype=np.int)
     for i in range(len(self.vlrep)):
         for j in self.vlrep[i]:
             self.x1[i, j] = 1
     self.mock = Mock()
     self.mock.getid.return_value = 0
     self.mock.getx.return_value = self.x1
     self.mock.gety.return_value = self.y
     self.mock.gettfill.return_value = self.tfill
     self.mock.getvlrep.return_value = self.vlrep
     self.mock.getopenbins.return_value = 8
Exemplo n.º 3
0
 def setUp(self):
     self.n = 24
     self.folder = 'tests/'
     file = 'Cookies24.txt'
     cookies = coolcookies.makeobjects(self.n, 6, self.folder + file)
     moop = mop.MOCookieProblem(self.n, 8, 15, 2, cookies)
     bpp = grasp.BPP(self.n, cookies, moop)
     self.gen = algorithm.Generation(self.n, 50, 750, cookies, bpp, moop)
     # Make sure calling this doesn't create problems, no specific test
     self.gen.initialq(self.folder + 'seed.txt')
Exemplo n.º 4
0
 def setUp(self):
     n = 1000
     batchsize = 100
     boxcap = 24
     rackcap = 300
     fillcap = 8
     cookies = coolcookies.makeobjects(n, batchsize, 'tests/Cookies1000.txt')
     self.moop = mooproblem.MOCookieProblem(n, boxcap, rackcap, fillcap, cookies)
     with open('tests/solution143.pkl', 'rb') as input:
         self.solution = pickle.load(input)
     self.solution = self.check_sol_for_rack_violations(self.solution)
 def setUp(self):
     storedchrom = np.load('tests/chrom0.npz')
     chrom = storedchrom[storedchrom.files[0]]
     self.n = len(chrom)
     storedtfill = np.load('tests/tfill0.npz')
     tfill = storedtfill[storedtfill.files[0]]
     cookies = coolcookies.makeobjects(self.n, 100, 'tests/Cookies1000.txt')
     bpp = bp.BPP(self.n, 24, 300, cookies)
     self.moop = mooproblem.MOCookieProblem(self.n, 24, 300, 8, cookies)
     self.gen = moma.Generation(self.n, 100, 200, cookies, bpp, self.moop)
     self.m = sols.MultiSol(0, chrom, tfill, bpp)
     self.m = self.gen.moop.calcfeasibility(self.m)
 def setUp(self):
     beta = 5
     n = 24
     cookies = coolcookies.\
         makeobjects(n, 6, '/Users/gelliebeenz/Documents/Python/ObjectiveMethod/'
                           'TimeDependent/ToyProblem/Cookies24.txt')
     self.moop = mop.MOCookieProblem(n, 8, 15, 2, cookies)
     self.newbie1 = grasp.NewSolution(beta, n, cookies, self.moop)
     self.newbie2 = grasp.NewSolution(beta, n, cookies, self.moop)
     self.newbie3 = grasp.NewSolution(beta, n, cookies, self.moop)
     self.newbie1.initialize_greedy_tfill()
     self.newbie1.open_new_bin(0, 0)
def moma(n, folder, datafile):
    existing_files = glob(folder + '*.out')
    filename = folder + 'run%d.out' % (len(existing_files) + 1)
    data = folder + datafile

    # Initialize algorithm
    batchsize = 100
    boxcap = 24
    rackcap = 300
    fillcap = 8
    pop = 100  # members per gen.
    end = 25000  # function evaluations
    # batchsize = 6
    # boxcap = 8
    # rackcap = 15
    # fillcap = 2
    # pop = 50            # members per gen.
    # end = 750           # function evaluations
    outf.startout(filename, n, end, data, 'MOMA')
    startt = datetime.now()
    print('                         ', startt)
    print(
        '*******************************************************************************'
    )
    print('     Method: MOMA\n')
    print('     data: ', datafile)
    print(
        '*******************************************************************************'
    )
    cookies = coolcookies.makeobjects(n, batchsize, data)
    moop = mop.MOCookieProblem(n, boxcap, rackcap, fillcap, cookies)
    bpp = BPP(n, boxcap, rackcap, cookies)
    gen = Generation(n, pop, end, cookies, bpp, moop)
    gen.initialp(folder + 'seed.txt')
    gen.makeq()

    # NSGA-II - Local search
    while not gen.endgen():
        gen.rungen()
        outf.genout(filename, gen.gett(), pop, gen.getq(), gen.getfnts())

    # Make output
    ndset = gen.finalapproxset()
    savefitvals(ndset, folder)
    savexys(ndset, folder)
    see(ndset, folder)
    outf.endout(filename)
    print('This algorithm has completed successfully.')
Exemplo n.º 8
0
def algorithm(n, folder, datafile):
    existing_files = glob(folder + '*.out')
    fname = folder + 'run%d.out' % (len(existing_files) + 1)
    data = folder + datafile

    # Initialize algorithm
    batchsize = 100
    boxcap = 24
    rackcap = 300
    fillcap = 8
    pop = 100           # members per gen.
    end = 25000         # function evaluations
    # batchsize = 6
    # boxcap = 8
    # rackcap = 15
    # fillcap = 2
    # pop = 50            # members per gen.
    # end = 750           # function evaluations
    outf.startout(fname, n, end, data, 'GAMMA-PC')
    startt = datetime.now()
    print('                         ', startt)
    print('*******************************************************************************')
    print('     Method: GAMMA-PC\n')
    print('     data: ', datafile)
    print('*******************************************************************************')
    cookies = coolcookies.makeobjects(n, batchsize, data)
    moop = mop.MOCookieProblem(n, boxcap, rackcap, fillcap, cookies)
    bpp = grasp.BPP(n, cookies, moop)
    gen = Generation(n, pop, end, cookies, bpp, moop)
    gen.initialq(folder + 'seed.txt')
    # Remove this after finishing
    import warnings
    warnings.simplefilter('error', RuntimeWarning)

    # Algorithm
    while not gen.endgen():
        outf.gen_probabilities(fname, gen.gett() + 1, **gen.get_probabilities())
        gen.rungen()
        outf.genout(fname, gen.gett(), pop, gen.getq(), gen.getarch(),
                    onlyapprox=True)

    # Make output
    ndset = gen.finalapproxset()
    savefitvals(ndset, folder)
    savexys(ndset, folder)
    see(ndset, folder)
    outf.endout(fname)
    print('This algorithm has completed successfully.')
 def setUp(self):
     #seed(56)
     chromstored = np.load('tests/chrom0.npz')
     chromname = chromstored.files
     self.chrom0 = chromstored[chromname[0]]
     tfillstored = np.load('tests/tfill0.npz')
     tfillname = tfillstored.files
     self.tfill0 = tfillstored[tfillname[0]]
     newgenesstored = np.load('tests/newgenes129.npz')
     newgenesfiles = newgenesstored.files
     self.chrom = newgenesstored[newgenesfiles[0]]
     self.tfill = newgenesstored[newgenesfiles[1]]
     self.tfill = np.reshape(self.tfill, 1000)
     cookies = coolcookies.makeobjects(1000, 100, 'tests/Cookies1000.txt')
     self.bpp = BPP(1000, 24, 300, cookies)
     self.moop = mooproblem.MOCookieProblem(1000, 24, 300, 8, cookies)
 def setUp(self):
     beta = 5
     n = 24
     cookies = coolcookies. \
         makeobjects(n, 6, '/Users/gelliebeenz/Documents/Python/ObjectiveMethod/'
                           'TimeDependent/ToyProblem/Cookies24.txt')
     self.moop = mop.MOCookieProblem(n, 8, 15, 2, cookies)
     self.newbie1 = grasp.NewSolution(beta, n, cookies, self.moop)
     self.chrom = [
         0, 1, 2, 8, 3, 4, 5, 7, 9, 10, 6, 11, 12, 13, 15, 16, 14, 17, 18,
         19, 21, 20, 22, 23
     ]
     self.tfill_suggested = np.array([
         1439, 1784, 3818, 3759, 2524, 4277, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0
     ])
     self.tfill_later = np.array([
         1790, 2371, 3288, 2470, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0
     ])
 def setUp(self):
     n = 24
     cookies = coolcookies.makeobjects(n, 6, 'tests/Cookies24.txt')
     moop = mooproblem.MOCookieProblem(n, 8, 15, 2, cookies)
     self.bpp = bp.BPP(n, 8, 15, cookies)
     self.gen = moma.Generation(n, 5, 10, cookies, self.bpp, moop)
Exemplo n.º 12
0
 def setUp(self):
     n = 1000
     cookies = coolcookies.makeobjects(n, 100, 'tests/Cookies1000.txt')
     self.moop = mooproblem.MOCookieProblem(n, 24, 300, 8, cookies)
Exemplo n.º 13
0
 def setUp(self):
     cookies = coolcookies.makeobjects(10, 2, 'tests/Cookies10.txt')
     moop = mooproblem.MOCookieProblem(10, 4, 8, 2, cookies)
     self.bpp = bp.BPP(10, moop.boxcap, 8, cookies)
     self.gen = nsgaii.Generation(10, 5, 10, cookies, self.bpp, moop)