Sep-25-2019, 10:33 AM
(This post was last modified: Sep-25-2019, 10:34 AM by Alex009988.)
I want to minimize this objective funrtion:
-10 000 000/100*(0*p0+100*p100)
with constraints
p0^56>=0.05
p0+p100=1
0<=p0<=1
0<=p100<=1
So that i used this code
I've tried trust-constr,SLSQP,TNC,L-BFGS-B,COBYLA and all cant find a solution.
Please, help me.
-10 000 000/100*(0*p0+100*p100)
with constraints
p0^56>=0.05
p0+p100=1
0<=p0<=1
0<=p100<=1
So that i used this code
import numpy as np from scipy.optimize import minimize def objective(p): p0=p[0] p100=p[1] return -10000000/100*(0*p0+100*p100) def constraint1(p): return p[0]**56-0.05 def constraint2(p): sum_p=1 for i in range(2): sum_p=sum_p-p[i] return sum_p p0=[0,0] p1=[0.94791, 0.0520895] #print(objective(p1)) b=(0.0,1.0) bnds=(b,b) con1={'type':'ineq','fun':constraint1} con2={'type':'eq','fun':constraint2} cons=[con1,con2] sol=minimize(objective,p0,method='SLSQP',bounds=bnds,constraints=cons) print(sol)The solution should be p0=0.94791, p100=0.0520895 and f(p)=-520 895.
I've tried trust-constr,SLSQP,TNC,L-BFGS-B,COBYLA and all cant find a solution.
Please, help me.