How to find minimum and maximum input values that a function is defined on
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I am trying to run fmincon on a function that is not defined over all input values. I would like to run fmincon over the entirety of the defined portion of the function. Is there any way to have matlab output the minimum and maximum input values permitted for a given function?
For context, my function is below. I can't hard code the min and max values because when I eventually run it in a for loop, I will be changing the values of beta_2o, which will then change the range of beta_1 values that are possible.
Any help would be appreciated!
% input initial conditions
T = 1000
beta_1o = 0.7
beta_2o = 0.7
g = 0.1
%function
f1 = @(beta_1)-(((T*beta_2o)/(0.5*(1+g)*beta_2o*beta_1+2*beta_1))^0.5+beta_1*(0.5*(1+g)*(T - ((T-beta_1)/(0.5*(1+g)*beta_1*beta_2o+2*beta_2o))-(T-beta_2o)/(0.5*(1+g)*beta_1*beta_2o+2*beta_1)))^0.5);
%fmincon functions
A = [];
b = [];
eq = [];
beq = [];
nonlcon = [];
x0 = [0]
lb = %lowest possible beta_1 allowed by f1?
ub = %highest possible beta_1 allowed by f1?
[xmin,fmin] = fmincon(f1,x0,A,b,eq,beq,lb,ub,nonlcon)
0 Commenti
Risposta accettata
Matt J
il 5 Mag 2022
Well, it doesn't make sense to be using fmincon for such a simple 1D problem here. You should just use fminbnd.
Either way, though, I would suggest doing a sweep of fun f1(beta_1) evaluations, not only to find an interval where f1 has a real value, but also to identify a local interval where the global optimum is likely to be found, and local optima avoided. Then you can apply fminbnd on a narrower, more targeted search interval. You can define f1 to return inf wherever a real value doesn't exist, so that fminbnd knows that it should look elsewhere for the optimum.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!