Optimization of a multivariable function

15 visualizaciones (últimos 30 días)
Mayele Matel
Mayele Matel el 10 de Ag. de 2011
Comentada: Ali Taheri el 10 de Feb. de 2022
Hello, I have this following problem: I want to minimize the function f=1054.4372-351.0852.*x(2)-72.9064.*x(3)+1416.2477.*x(1).^2-349.3091.*x(1).*x(2)+81.2973.*x(1).*x(4)+815.8691.*x(2).^2-1076.9907.*x(1).^3+952.576.*x(1).^2.*x(2)+578.7052.*x(1).*x(2).^2-113.2848.*x(1).*x(3).^2-57.5303.*x(1).*x(3).*x(4)-121.6719.*x(1).*x(4).^2-1131.8391.*x(2).^3+107.4973.*x(2).^2.*x(4)+64.6476.*x(2).*x(3).*x(4)+91.0026.*x(3).*x(4).^2-134.1675.*x(4).^3;
on the following Intervals: x1=1:1:100; x2=0.1:0.1:10; x3=1:10:1000; x4=1:1:100; is there any Matlab's Optimization tool to solve this problem? if yes, please discribe me how I should process? Thanks Maty

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Ag. de 2011
The standard MATLAB optimizers are continuous optimizers, not discrete variable optimizers.
So write,
x1r = 1:1:100; x2r = 0.1:0.1:10; x3r = 1:10:1000; x4r = 1:1:100;
[x1,x2,x3,x4] = ndgrid(x1r, x2r, x3r, xr4);
f = 1054.4372 - 351.0852 .* x2 - 72.9064 .* x3 + 1416.2477 .* x1 .^2 - 349.3091 .* x1 .* x2 + 81.2973 .* x1 .* x4 + 815.8691 .* x2 .^2 - 1076.9907 . *x1 .^3 + 952.576 .* x1 .^2 .* x2 + 578.7052 .* x1 .* x2 .^2 - 113.2848 .* x1 .* x3 .^2 - 57.5303 .* x1 .* x3 .* x4 - 121.6719 .* x1 .* x4 .^2 - 1131.8391 .* x2 .^3 + 107.4973 .* x2 .^2 .* x4 + 64.6476 .* x2 .* x3 .* x4 + 91.0026 .* x3 .* x4 .^2 - 134.1675 .* x4 .^3;
(minfval, minidx) = min(f(:));
minimal = [minfval, x1(minidx), x2(minidx), ...
x3(minidx), x4(minidx)];
  3 comentarios
Walter Roberson
Walter Roberson el 9 de Feb. de 2022
xr{1} = 1:1:10; xr{2} = 0.1:0.1:10; %and so on
NumberOfIntervals = length(xr);
x = cell(1,NumberOfIntervals);
[x{:}] = ndgrid(xr{:});
f = 1054.4372 - 351.0852 .* x{2} - 72.9064 .* x{3} + 1416.2477 .* x{1}.^2 - 349.3091 .* x{1} .* x{2} + 81.2973 .* x{1} .* x{4} + 815.8691 .* x{2}.^2 - 1076.9907 .* x{1}.^3 + 952.576 .* x{1}.^2 .* x{2} + 578.7052 .* x{1} .* x{2}.^2 - 113.2848 .* x{1} .* x{3}.^2 - 57.5303 .* x{1} .* x{3} .* x{4} - 121.6719 .* x{1} .* x{4}.^2 - 1131.8391 .* x{2}.^3 + 107.4973 .* x{2}.^2 .* x{4} + 64.6476 .* x{2} .* x{3} .* x{4} + 91.0026 .* x{3} .* x{4}.^2 - 134.1675 .* x{4}.^3;
(minfval, minidx) = min(f(:));
min_at = cellfun(@(XR) XR(minidx), xr);
minimal = [minfval, min_at];
However: if you do not know the number of intervals ahead of time, then you do not know the expression for f ahead of time, and it is potentially tricky to compute the expression, depending on what information you have available about what the expression should be.
Also, beware that the number of points in the ndgrid() results increases rapidly with the number of intervals, so this approach of creating all of the grid elements ahead of time is not always suitable.
If an exhaustive search is going to be larger than your available memory, then there are different ways of proceeding, that depend upon whether you really need the exhaustive search (guaranteed absolute minimum of the function over the discrete points), or if just just need "a good try". If you need a "good try", then using ga() with discrete bounds can be useful. If you need exhaustive search that is larger than memory, there are multiple approaches, including using my "odometer" approach; https://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22odometer%22
Ali Taheri
Ali Taheri el 10 de Feb. de 2022
Thanks for your prompt and correct reply. My problem was solved.
But for those who will be reading this page, the answer needs to be slightly edited. In line six, on the left side, the "()" should be replaced with "[]". In line seven, xr should be replaced by x.
Thanks for your valuable tips. The expression of f is determined as a cycle depending on the number of intervals and there is no problem with it. Also the number of intervals is limited. I will ask you if I need to ga() and the "odometer" approach.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surrogate Optimization en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by