I’m going to implement the following code (Python) in Math.Net:
def fun():
#somecode
return v
def con(args):
x1min, x1max, x2min, x2max= args
cons = ({'type': 'ineq', 'fun': lambda x: x[0] - x1min},
{'type': 'ineq', 'fun': lambda x: -x[0] + x1max},
{'type': 'ineq', 'fun': lambda x: x[1] - x2min},
{'type': 'ineq', 'fun': lambda x: -x[1] + x2max})
return cons
args1 = (0.5,1500,0,30) #x1min, x1max, x2min, x2max
cons = con(args1)
x0 = np.asarray((2,1.5))
best = op.minimize(fun(), x0, constraints=cons,options={
'maxiter': 10000,
'maxfun': 50000
})
print(best)
With BfgsBMinimizer, I don’t have the ‘Gradient’ function.
With Neldermeadex, I don’t know how to bound the variables.
I need some help,thx.
1 post - 1 participant