I'm trying to find the minimum of a function with thirteen variables. Am I doing everything right? Tell me, how do I add restrictions?

2 次查看(过去 30 天)
I'm trying to find the minimum of a function with thirteen variables. Am I doing everything right? Tell me, how do I add restrictions?
in short, I solve the problem of optimizing the electrical network by installing reactive power compensating devices.
function F = multiObjFcn(optimInput)
x(1) = optimInput(1);
x(2) = optimInput(2);
x(3) = optimInput(3);
x(4) = optimInput(4);
x(5) = optimInput(5);
x(6) = optimInput(6);
x(7) = optimInput(7);
x(8) = optimInput(8);
x(9) = optimInput(9);
x(10) = optimInput(10);
x(11) = optimInput(11);
x(12) = optimInput(12);
x(13) = optimInput(13);
F(1) = 23.37*0.05*((sqrt(100^2+(90-x(1))^2))/(sqrt(3)*10^2)...
+(sqrt(150^2+(130-x(2))^2))/(sqrt(3)*10^2)...
+(sqrt(210^2+(180-x(3))^2))/(sqrt(3)*10^2)...
+(sqrt(600^2+(450-x(6))^2))/(sqrt(3)*10^2)...
+(sqrt(400^2+(390-x(7))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(8))^2))/(sqrt(3)*10^2)...
+(sqrt(150^2+(130-x(9))^2))/(sqrt(3)*10^2)...
+(sqrt(180^2+(162-x(10))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(13))^2))/(sqrt(3)*10^2))+266.214+0.256*(x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x(10)+x(11)+x(12)+x(13))...
+23.37*0.05*((sqrt(180^2+(162-x(10))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(13))^2))/(sqrt(3)*10^2))...
+23.37*0.05*((sqrt(400^2+(390-x(7))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(8))^2))/(sqrt(3)*10^2)...
+(sqrt(150^2+(130-x(9))^2))/(sqrt(3)*10^2)...
+(sqrt(180^2+(162-x(10))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(13))^2))/(sqrt(3)*10^2))...
+23.37*0.05*((sqrt(210^2+(180-x(3))^2))/(sqrt(3)*10^2)...
+(sqrt(600^2+(450-x(6))^2))/(sqrt(3)*10^2)...
+(sqrt(400^2+(390-x(7))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(8))^2))/(sqrt(3)*10^2)...
+(sqrt(150^2+(130-x(9))^2))/(sqrt(3)*10^2)...
+(sqrt(180^2+(162-x(10))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(13))^2))/(sqrt(3)*10^2))...
+23.37*0.05*((sqrt(100^2+(90-x(1))^2))/(sqrt(3)*10^2)...
+(sqrt(150^2+(130-x(2))^2))/(sqrt(3)*10^2)...
+(sqrt(210^2+(180-x(3))^2))/(sqrt(3)*10^2)...
+(sqrt(600^2+(450-x(6))^2))/(sqrt(3)*10^2)...
+(sqrt(400^2+(390-x(7))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(8))^2))/(sqrt(3)*10^2)...
+(sqrt(150^2+(130-x(9))^2))/(sqrt(3)*10^2)...
+(sqrt(180^2+(162-x(10))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(13))^2))/(sqrt(3)*10^2));
end
  11 个评论
Ivan
Ivan 2024-2-27
Well, first of all, my variables must have a limit - no lower than a certain value. Secondly, these variables must take discrete values from a certain list with a certain numerical step. Then I want to add a component that will take a random value from a certain range.
Walter Roberson
Walter Roberson 2024-2-27
I suggest you use Problem Based Optimization
Otherwise, you need to use ga() to handle the discrete values.
If the discrete values happen to be integers, then use lb and ub to establish natural bounds, and mark those variables as being restricted to integers.
If the discrete values do not happen to be integers, then use substitute integer variables with lower bound 0 and upper bound (number of discrete states minus one), and then in your code do a transformation (VALUE * NUMERIC_STEP + MINIMUM)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by