Constrained Optimisation in MATLAB
이전 댓글 표시
I have a 11x11 matrix A with set of values.I have an another 11x1 matrix B with set of values
Resultant, C=(transpose(B)*A)* A; D= 30/C;
My objective function is to maximize D by changing the values of Matrix B subject to the following constraints 1) The values of 11x1, Matrix B should be between upper and lower bound The matrix B is imagined to be split into upper half of 7 elements and lower half of 4 elements 2) The number of elements whose value changes in the upper half of matrix B should be less than or equal to 3 3) The number of elements whose value changes in the lower half of matrix B should be less than or equal to 2
I have attached the script for your reference. fun1 is the function which has a output D and I want to maximize D. Script is the script which I coded
Experts, I need some help on this. Thanks in advance.
댓글 수: 6
Torsten
2016년 5월 24일
And what do you mean by maximizing the vector C ?
Best wishes
Torsten.
Karthick Jonagadla
2016년 5월 24일
Karthick Jonagadla
2016년 5월 24일
Torsten
2016년 5월 24일
But you multiply transpose(B)*A with A, which gives a (1x15) vector.
Best wishes
Torsten.
Karthick Jonagadla
2016년 5월 24일
편집: Karthick Jonagadla
2016년 5월 24일
답변 (3개)
Bjorn Gustavsson
2016년 5월 24일
Have a look at
fmincon
or if you don't have the optimization toolbox, you can find several useful entries at the file exchange. Look for the fminsearchbnd and minimize submissions
HTH
Torsten
2016년 5월 24일
0 개 추천
Conditions 2 and 3 give (7C3)*(4C2)=210 cases to be considered. (nCk = n!/(k!*(n-k)!)
I think the easiest way would be to use fmincon to calculate these 210 cases and to extract the one with largest value of the objective.
Best wishes
Torsten.
Bjorn Gustavsson
2016년 5월 24일
It seems your source code is different again from what you seem to want to do.
I'll assume that the problem you want to solve is this:
% min(C) where C is
C = (transpose(B)*A)*B; % this at least makes C scalar
B0 = ones(11,1);
fcn = @(B) (transpose(B)*A)*B;
UB = [ones(7,1)*3;ones(4,1)*2];
Boptimal = fmincon(fcn,B0,eye(length(B)),UB);
HTH
댓글 수: 2
Karthick Jonagadla
2016년 5월 24일
편집: Karthick Jonagadla
2016년 5월 24일
Bjorn Gustavsson
2016년 5월 24일
Well your problem is at least in one other place...
The equation for C in your original question gives a 1x11 array. Which makes your equation for D less than desirably suitable for optimization. That expression does not agree with your fun1.m. When I run that with the following input I get some errors. Your first effort should be to make that one work...
type fun1
function [D] = fun1(A,B)
C = (transpose(A)*B)* A;
C = sqrt(C);
D = (30)/C;
D = -1*D;
>> A = randn(11);
>> B = rand(11,1);
>> D = fun1(A,B)
Error using *
Inner matrix dimensions must agree.
Error in fun1 (line 2)
C = (transpose(A)*B)* A;
>> D = fun1(A,B.')
Error using *
Inner matrix dimensions must agree.
Error in fun1 (line 2)
C = (transpose(A)*B)* A;
>> C=(transpose(B)*A)* A; D= 30/C;
Error using /
Matrix dimensions must agree.
Now looking into your script it seems that you
1, call the function with the inputs from your description swapped.
2, In your definition of the function you optimize you don't use the weights input parameter.
You'll get some output by changing the script to:
f = @(W) fun1(W,C);
[Out1,Out2,Out3]= fmincon(f,R,A,B,Aeq,Beq,ILB,IUB,[],options);
Hopefully that is a solution to your problem.
HTH
카테고리
도움말 센터 및 File Exchange에서 Detection에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!