assign different objective function to different data sets in a loop
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Alan Weiss
2017년 5월 15일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!