python - scipy.optimize for vector function -


i want minimize function has multiple inputs multible outputs. more specific, call excel calculation , want constrain particular inputs , outputs of function. far managed minimize scalar function meaning multible inputs 1 output. can please guide me if such problem can solved python/scipy? i´d choose x smpkt minimized , smaller particular value.

for example code snippets:

def f1(x,params):     y=f(x) 

the function f(x) external excel sheet multiple inputs , outputs, output should y=[smpkt,a]. i´d minimize smpkt , keep a smaller constraint choosing x.

so far managed minimize y=f(x) y=[smpkt] scalar following call:

res = optimize.minimize(f1, x0, args=params, method='cobyla',options={'ftol': 0.1, 'maxiter': 5}) 

any idea?

note: i'm not sure following want do. in particular, "i'd keep variable "a" smaller particular value.", not same "i want choose x a small possible.". it's worth, here's answer 1 interpretation of question.

if want minimize 1 component of output, suggested comments function f1 (and can't modify f1 return a), you'll need wrap existing function in function calls f1 , returns a (assuming a is, in fact, scalar).

e.g.

def objective_function(x, params):     smpkt, = f1(x, params)     return 

you accomplish same effect more concisely lambda expression:

res = optimize.minimize(lambda x, params: f1(x, params)[1],                         x0, args=params, method='cobyla',                         options={'ftol': 0.1, 'maxiter': 5}) 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -