Optimisation

27 views (last 30 days)
Mayele Matel
Mayele Matel on 11 Aug 2011
Hi Walter,
Thank you for the answewer for my optimization problem
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, x4r);
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)];
but it is not satisfactory.
1 - it took many time to the result
2 - I got zero as value for x1, x2, x3 and x4. these variables are supposed to be greater and equal 1.
Best regards

Answers (1)

Walter Roberson
Walter Roberson on 11 Aug 2011
There is no way that x1 or x2 or x3 or x4 could have come out 0 in that code. However, especially if you had "format short" in effect, the high value for the function value would have scaled the first digits of the other values out of existence. Command
format long g
before displaying the value of "minimal".
When I execute that code, I get
minimal =
-12298691493.8081 100 0.1 991 41
If you use continuous variables instead of discrete variables, the 991 moves to 100 and the 41 becomes approximately 40.6

Categories

Find more on Problem-Based Optimization Setup in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!