assign different objective function to different data sets in a loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I was wondering if someone can help me with this. How I can create different obj. function for different data sets? Up to now it can be written as:
matlabFunction(totR1,'vars',{X},'file','objFcn1');
matlabFunction(totR2,'vars',{X},'file','objFcn2');
matlabFunction(totR3,'vars',{X},'file','objFcn3');
This is for 3 data sets. But in reality I will have more than 2000 data sets. Is there a way to create those 2000 diff. objective functions in a more robust way and keeping them in an internal memory maybe (without really writing them?).
And the next question that is in addition to the first one is: how I can also evaluate those 3...2000 obj.fn using fmincon e.g.
For one data set it works fine:
options = optimset('MaxFunEvals',Inf,'MaxIter',5000,...
'Algorithm','interior-point','Display','iter');
tic
for i=1:3
[x1(:,i), fval1(1,i)] =fmincon(@objFcn2,x0(:,i),A,b(:,i),Aeq,beq(:,i),LB(:,i),UB(:,i),[],options);
end
toc
for i=1:3 (###for each data sets but it uses the same obj.fun what is not OK, in this case objfcn2)
I would like to evaluate for i=1 it should take objfcn1, for i=2 objfcn2 and so on... for i=2000 it should take objfcn2000.
Thanks a lot
M.
0 Kommentare
Antworten (1)
Alan Weiss
am 15 Mai 2017
I am not at all sure that this will help you, but if your objective functions are all basically the same, but simply reflect different data, then it is possible that you can use just one call to matlabFunction and pass in the data to the resulting function. For an example, see Symbolic Derivatives for Econometric Tests.
Alan Weiss
MATLAB mathematical toolbox documentation
0 Kommentare
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!