Fmincon optmization linear equality in a loop
조회 수: 2(최근 30일)
I have the following optimization problem: I have data on two vectors A and L of size 39x1 each representing in economic terms assets and liabilities of 39 agents. Each agent optimizes his assets and liabilities via an objective function and subject to some constraints. Hence each agent's problem is solved via fmincon which produces a 2x1 vector and I call it 39 times via a loop:
% Aeq=[1 1];
I store each solution to xx which is a 39x2 matrix containing the solutions for all agents. My problem is that I need the sum of xx(:,1) and the sum of xx(:,2) representing total assets and liabilities to be equal to the sum of my original data A and L respectively (which are used as initial values) so sum(D)=sum(A) and sum(S)=sum(L). By construction sum(A)=sum(L). Is there a way to achieve this in this setting? I tried a crude approximation of having each agent's sum of assets and liabilities to be equal to his original sum of A and L via the commented Aeq and Beq linear equalities but it is not a satisfactory answer as I need it to hold only for all of them but not individually necessarily.
Any useful recommendations are greatly appreciated. Thank you.
P.S. in reality this is a nested optimization since I call the function containing this loop in another one that minimizes the output EG (essentially finding the value of a parameter p that makes D=S). I am not sure whether this helps but thought it would be useful to mention.
Matt J 2017년 6월 11일
편집: Matt J 2017년 6월 11일
My problem is that I need the sum of xx(:,1) and the sum of xx(:,2) representing total assets and liabilities to be equal to the sum of my original data A and L respectively
If that's the case, then you cannot pose this as 39 separate optimization problems. You have to solve for all xx(i,:) simultaneously. You would probably do this by implementing a new objective function that is the sum of all the individual objectives of the 39 agents. The equality constraint on the totals of xx would be implemented as
Aeq=[ones(1,39),zeros(1,39) ; zeros(1,39),ones(1,39)];