Пример #1
0
rSLSQP = pro.solve('ralg')

pro = NLP(f=objLegrand.cost,x0=rPswarm.xf,df=objLegrand.sensitivity,lb=lb,ub=ub,A=A,b=b)
pro.plot = True
rSLSQP = pro.solve('scipy_slsqp')



objLegrand.cost(rPswarm.xf)
objLegrand.cost()
gSens,output=objLegrand.sensitivity(full_output=True)
solution = output['sens'][:,:6]

# here we pretend the bounds don't exist
pro2 = GLP(f=objLegrand.cost,x0=theta,df=objLegrand.sensitivity,lb=lb,ub=ub)
pro2.plot = True
r2 = pro2.solve('galileo')

pro = GLP(f=objLegrand.cost,x0=theta,df=objLegrand.sensitivity,lb=lb,ub=ub,A=A,b=b)
pro.plot = True
rDe = pro.solve('de')

pro = GLP(f=objLegrand.cost,x0=theta,lb=lb,ub=ub,A=A,b=b)
pro.plot = True
rPswarm = pro.solve('pswarm',size=100)

pro = GLP(f=objLegrand.cost,x0=rPswarm.xf,lb=lb,ub=ub,A=A,b=b)
pro.plot = True
rPswarm = pro.solve('pswarm',size=100,maxIter=1000,maxFunEvals=100000)

Пример #2
0
# y = copy.copy(solution[:,1:2])
# y[1::] = y[1::] + numpy.random.normal(loc=0.0,scale=0.1,size=numStep-1)

# odeSIR = odeLossFunc.squareLoss([0.5,1.0/3.0] ,ode,x0,t0,t[1:len(t)],y[1:len(t)],'R')

objSIR = odeLossFunc.squareLoss(theta, ode, x0, t0, t[1::], solution[1::, 1:3],
                                ['I', 'R'])

box = [(0., 2.), (0., 2.)]
npBox = numpy.array(box)
lb = npBox[:, 0]
ub = npBox[:, 1]

pro = GLP(f=objSIR.cost, x0=theta, lb=lb, ub=ub)
pro.plot = True
rGalileo = pro.solve('galileo')

pro = GLP(f=objSIR.cost, x0=theta, lb=lb, ub=ub)
pro.plot = True
rDe = pro.solve('de')

pro = GLP(f=objSIR.cost, x0=theta, lb=lb, ub=ub)
pro.plot = True
rPSwarm = pro.solve('pswarm')

pro = NLP(f=objSIR.cost, df=objSIR.sensitivity, x0=theta, lb=lb, ub=ub)
pro.plot = True
rLincher = pro.solve('lincher')

pro = NLP(f=objSIR.cost, x0=theta, df=objSIR.sensitivity, lb=lb, ub=ub)
Пример #3
0
          A=A,
          b=b)
pro.plot = True
rSLSQP = pro.solve('scipy_slsqp')

# GLP
pro = GLP(f=objLegrand.cost, x0=theta, df=objLegrand.sensitivity, lb=lb, ub=ub)
pro.plot = True
rPswarm = pro.solve('pswarm')

pro2 = GLP(f=objLegrand.cost,
           x0=rPswarm.xf,
           df=objLegrand.sensitivity,
           lb=lb,
           ub=ub)
pro2.plot = True
rPswarm2 = pro2.solve('pswarm')

pro3 = NLP(f=objLegrand.cost,
           x0=rPswarm2.xf,
           df=objLegrand.sensitivity,
           lb=lb,
           ub=ub)
pro3.plot = True
rPswarm3 = pro3.solve('ralg')

pro2 = GLP(f=objLegrand.cost,
           x0=theta,
           df=objLegrand.sensitivity,
           lb=lb,
           ub=ub)
Пример #4
0
theta = [0.2,0.2]

# y = copy.copy(solution[:,1:2])
# y[1::] = y[1::] + numpy.random.normal(loc=0.0,scale=0.1,size=numStep-1)

# odeSIR = odeLossFunc.squareLoss([0.5,1.0/3.0] ,ode,x0,t0,t[1:len(t)],y[1:len(t)],'R')

objSIR = odeLossFunc.squareLoss(theta,ode,x0,t0,t[1::],solution[1::,1:3],['I','R'])

box = [(0.,2.),(0.,2.)]
npBox = numpy.array(box)
lb = npBox[:,0]
ub = npBox[:,1]

pro = GLP(f=objSIR.cost,x0=theta,lb=lb,ub=ub)
pro.plot = True
rGalileo = pro.solve('galileo')

pro = GLP(f=objSIR.cost,x0=theta,lb=lb,ub=ub)
pro.plot = True
rDe = pro.solve('de')

pro = GLP(f=objSIR.cost,x0=theta,lb=lb,ub=ub)
pro.plot = True
rPSwarm = pro.solve('pswarm')

pro = NLP(f=objSIR.cost,df=objSIR.sensitivity,x0=theta,lb=lb,ub=ub)
pro.plot = True
rLincher = pro.solve('lincher')

pro = NLP(f=objSIR.cost,x0=theta,df=objSIR.sensitivity,lb=lb,ub=ub)