Borrar filtros
Borrar filtros

How to minimize a complicated function?

4 visualizaciones (últimos 30 días)
Grace
Grace el 19 de Jun. de 2014
Comentada: Roger Stafford el 22 de Jun. de 2014
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.

Respuestas (1)

Roger Stafford
Roger Stafford el 19 de Jun. de 2014
Editada: Roger Stafford el 19 de Jun. de 2014
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 comentarios
Grace
Grace el 21 de Jun. de 2014
Editada: Grace el 21 de Jun. de 2014
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 el 22 de Jun. de 2014
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'.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by