Help me figure out what the error is. This is the first time I use matlab. Optimization problem with thirteen variables.
3 次查看(过去 30 天)
显示 更早的评论
My task is to solve the target function, which is the sum of the total costs of purchasing and using reactive power compensation devices in medium voltage electrical networks. I need to minimize it.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601531/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601531/image.png)
For now, conditionally, there should be a reactive power compensation device(PCD) on each load.
I have formed a target function from three variables (capital costs, costs of energy loss in the network and costs depending on the reliability of the system).![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601536/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601536/image.png)
Since the third variable does not depend on the PCD, it can be ignored. I have divided the target function into two to find their minima. I'll shorten the calculations, the final function in the matlab looks like this:
function f=fun1_optim(x)
f(1) = 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));
f(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(300^2+(250-x(4))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(5))^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(600^2+(450-x(11))^2))/(sqrt(3)*10^2)...
+(sqrt(500^2+(470-x(12))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(13))^2))/(sqrt(3)*10^2));
and here is the error:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601541/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601541/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601546/image.png)
I sincerely don't understand what they want from me. Please help me.
1 个评论
回答(1 个)
Torsten
2024-1-27
x0 = zeros(13,1);
lb = zeros(13,1);
ub = inf(13,1);
sol = fmincon(@fun1_optim,x0,[],[],[],[],lb,ub)
fun1_optim(sol)
function F=fun1_optim(x)
f(1) = 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));
f(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(300^2+(250-x(4))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(5))^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(600^2+(450-x(11))^2))/(sqrt(3)*10^2)...
+(sqrt(500^2+(470-x(12))^2))/(sqrt(3)*10^2)...
+(sqrt(100^2+(90-x(13))^2))/(sqrt(3)*10^2));
F = f(1) + f(2);
end
15 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!