How to minimize a complicated function?

조회 수: 2 (최근 30일)
Grace
Grace 2014년 6월 19일
댓글: Roger Stafford 2014년 6월 22일
Hi, I have a function
function ces=mat(UT)
U=UT;
[n,s]=size(U);
X=(2*U-1)/(2*n);
cs1=zeros(n,1);
for k=1:n
CSP=1;
for i=1:s
CSP=CSP*(2+abs(X(k,i)-1/2)-(X(k,i)-1/2)^2);
end
cs1(k)=CSP;
end
Ces=sum(cs1);
UT is any nxs matrix with a condition each elements in each column must be from 1:n with no repetition, for example:
1 3
2 2
3 1
4 4
I want to minimize this function to find UT, is it possible for me to do this?
Thank you.

답변 (1개)

Roger Stafford
Roger Stafford 2014년 6월 19일
편집: Roger Stafford 2014년 6월 19일
In your statement, "I want to minimize this function to find UT", do you mean that you want to so adjust the matrix 'UT' that the value of 'ces' is minimized? If that is your meaning, minimizing 'ces' is very far from uniquely determining 'UT'.
For example, using your case of n = 4 and s = 2, there are (4!)^2 = 576 possible values for UT, but only three possible values for 'ces'. The minimum of these, namely 4*135*143/64^2, will occur in 96 of those 576 cases or one-sixth of the time. That is certainly far from being uniquely determined. Notice that among other possible changes in 'UT', permuting its rows, of which there are 24 possibilities, will always leave 'ces' unchanged.
For larger values of n and s the lack of uniqueness in 'UT' at the minimum will become even more pronounced.
Note that your method of computing the 'mat' function can easily be vectorized. Perhaps that is what you actually meant by "minimize". If so, that is not the proper way to describe your question.
function ces = mat(UT)
X = (2*UT-1)/2/size(UT,1)-1/2;
ces = sum(prod(2+abs(X)-X.^2,2));
  댓글 수: 2
Grace
Grace 2014년 6월 21일
편집: Grace 2014년 6월 21일
Yes, I want to adjust the matrix 'UT' that the value of 'ces' is minimized. If minimizing 'ces' is far from uniquely determining 'UT', what can I do to know the possible arrangements of 'UT' which give me the lowest value of 'ces' instead of using minimization? Thank you.
Roger Stafford
Roger Stafford 2014년 6월 22일
At present I can only speak for the case when your s is equal to 2 - that is, when UT has just two columns. For n = 6 the quantity
2+abs(X(k,i)-1/2)-(X(k,i)-1/2)^2
can assume only three possible values, 299/144, 315/144, and 323/144. You will obtain the minimum value for 'ces' when in each row either 299/144 is paired with 323/144 or else 315/144 is paired with another 315/144. For example, as you can easily check, this would be true for
UT = [5 2;3 6;2 5;1 3;4 1;6 4]
Out of a total of 518,400 possible UT matrices of this size, 5,760 of them will satisfy this requirement and give the same minimum value, namely, 584758/20736.
This actually holds true for any three unequal values above, not just the three you are using. If the largest and smallest are always paired together and the middle value paired with itself, you will get a minimum 'ces'.
I have also checked this with n = 4 and I have reason to suspect that a similar kind of relation holds for all values of n. Still assuming s = 2, always pair the above values with each other in reverse order: the largest with the smallest, the next largest with the next smallest, etc., and I believe you will get a minimum value for 'ces'.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by