Exemplo n.º 1
0
def PESIS(ojf, lb, ub, ki, b, fname):
    sp.random.seed(int(os.urandom(4).encode('hex'), 16))
    para = dict()
    para['kindex'] = ki[0]
    para['mprior'] = ki[1]
    para['sprior'] = ki[2]
    para['s'] = -1.
    para['ninit'] = 10
    para['volper'] = 1e-6
    para['DH_SAMPLES'] = 12
    para['DM_SAMPLES'] = 12
    para['DM_SUPPORT'] = 1200
    para['DM_SLICELCBPARA'] = 1.
    para['SUPPORT_MODE'] = [ESutils.SUPPORT_LAPAPR]
    if os.path.exists(fname):
        print "starting from " + str(fname)
        OE = OPTutils.PESIS(ojf,
                            lb,
                            ub,
                            para,
                            initstate=pickle.load(open(fname, 'rb')))
    else:
        print "fresh start"
        OE = OPTutils.PESIS(ojf, lb, ub, para)
    if sum(OE.C) >= b:
        print "no further steps needed"
        k = 0
        while sum(OE.C[:k]) < b:
            print "used {0} of {1} eval budget".format(sum(OE.C), b)
            k += 1
        state = [
            OE.X[:k, :], OE.Y[:k, :], OE.S[:k, :], OE.D[:k], OE.R[:k, :],
            OE.C[:k], OE.T[:k], OE.Tr[:k], OE.Ymin[:k], OE.Xmin[:k, :],
            OE.Yreg[:k, :], OE.Rreg[:k, :]
        ]
    else:
        while sum(OE.C) < b:
            print "used {0} of {1} eval budget".format(sum(OE.C), b)
            OE.step()
        state = [
            OE.X, OE.Y, OE.S, OE.D, OE.R, OE.C, OE.T, OE.Tr, OE.Ymin, OE.Xmin,
            OE.Yreg, OE.Rreg
        ]
        pickle.dump(state, open(fname, 'wb'))
    return state
Exemplo n.º 2
0
    O.step()


para = dict()
para['kindex'] = GPdc.SQUEXPCS
para['mprior'] = sp.array([0.]+[-1.]*d+[-2.])
para['sprior'] = sp.array([1.]*(d+1)+[2.])
#para['s'] = 1e-6
para['ninit'] = 10
#para['maxf'] = 2500
para['volper'] = 1e-7
para['DH_SAMPLES'] = 8
para['DM_SAMPLES'] = 8
para['DM_SUPPORT'] = 400
para['DM_SLICELCBPARA'] = 1.
para['SUPPORT_MODE'] = ESutils.SUPPORT_SLICELCB
OP = OPTutils.PESIS(ojf,lb,ub,para)
for i in xrange(15):
    try:
        OP.step()
    except RuntimeError as e:
        print e
        break

f,a = plt.subplots(7)
O.plot(truexmin,a,'b')
#OE.plot(truexmin,a,'r')
OP.plot(truexmin,a,'g')
#OL.plot(truexmin,a,'c')

plt.show()