How do I estimate 15 parameters with the least square method for a non-linear objective function MATLAB?

2 views (last 30 days)
I want to estimate the parameters x1-x15 with the least square method in MATLAB. My objective function is:
sum((Pot-Potcap).^2)
Pot = x(14)*exp(-(t*log(x(1)*x(15) + 1))/x(15)) + x(14)*(exp(-(t*log(x(3)*x(15) + 1))/x(15)) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/(x(2) - x(3)) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(3))*(x(2) - x(3)))) + x(14)*(exp(-(t*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t*log(x(3)*x(15) + 1))/x(15)))/(x(3) - x(4)) + (x(7)*x(8)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) - x(13)*(exp(-(t*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t*log(x(3)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(7)*x(8)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) + x(14)*(exp(-(t*log(x(2)*x(15) + 1))/x(15)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/(x(1) - x(2))) + x(12)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4))*(x(3) - x(5)))/(x(8)*x(9)) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(3))*(x(2) - x(3)))) - x(13)*((exp(-(t*log(x(4)*x(15) + 1))/x(15))*(x(4) - x(5)))/x(9) + (x(8)*exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/(x(9)*(x(3) - x(4))) + (x(7)*x(8)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) + x(12)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4)))/(x(4) - x(5)) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) + x(14)*(exp(-(t*log(x(5)*x(15) + 1))/x(15)) + (x(9)*exp(-(t*log(x(4)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(8)*x(9)*exp(-(t*log(x(3)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(7)*x(8)*x(9)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*x(9)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(5))*(x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(13)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/x(9) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(2)))) + x(12)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(2)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4))*(x(2) - x(5)))/(x(7)*x(8)*x(9)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)*(x(1) - x(2)))) - x(13)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(3))*(x(2) - x(3)))) + x(12)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) - (x(13)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/x(9) + (x(12)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) - (x(11)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(6)*x(7)*x(8)*x(9))
for the data Potcap and t from 1 to 21. I have tried using the code:
x = sym('x', [1 15], 'real')
t = [1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21]
x0 = [0.2;0.21;0.22;0.23;0.24;0.31;0.32;0.33;0.34;0.1;0.1;0.1;0.1;0.1;0.3]
lb = zeros(21,1)
ub = [Inf Inf Inf Inf Inf Inf Inf Inf Inf 1 1 1 1 1 Inf]
fnc = @(x) Fungsi(x,t,Potcap);
[p,fval] = fmincon(fnc,x0,[],[],[],[],lb,ub,@mycon)
function f = Fungsi(x, t, Potcap)
f = sum(((x(14)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)) + x(14)*(exp(-(t.*log(x(3)*x(15) + 1))/x(15)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/(x(2) - x(3)) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(3))*(x(2) - x(3)))) + x(14)*(exp(-(t.*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/(x(3) - x(4)) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) - x(13)*(exp(-(t.*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) + x(14)*(exp(-(t.*log(x(2)*x(15) + 1))/x(15)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/(x(1) - x(2))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4))*(x(3) - x(5)))/(x(8)*x(9)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(3))*(x(2) - x(3)))) - x(13)*((exp(-(t.*log(x(4)*x(15) + 1))/x(15))*(x(4) - x(5)))/x(9) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/(x(9)*(x(3) - x(4))) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4)))/(x(4) - x(5)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) + x(14)*(exp(-(t.*log(x(5)*x(15) + 1))/x(15)) + (x(9)*exp(-(t.*log(x(4)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(8)*x(9)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(7)*x(8)*x(9)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*x(9)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(5))*(x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(13)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/x(9) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(2)))) + x(12)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(2)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4))*(x(2) - x(5)))/(x(7)*x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)*(x(1) - x(2)))) - x(13)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(3))*(x(2) - x(3)))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) - (x(13)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/x(9) + (x(12)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) - (x(11)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(6)*x(7)*x(8)*x(9)))-Potcap).^2);
end
function [c,ceq] = mycon(x)
c = []
ceq = (x(10)+x(11)+x(12)+x(13)+x(14))==1
end
But running the code above meets an error saying "FMINCON requires all values returned by functions to be of data type double". I have tried many things to fix this error but it still persists. Any suggestions for the problem I have or alternatives to using the code above? Thanks.
  5 Comments
Rex Mantiri
Rex Mantiri on 11 Dec 2021
Potcap = [0.986702168; 0.97272091; 0.957930961; 0.942424001; 0.926404439; 0.909375829; 0.891635315; 0.873329497; 0.854253377; 0.834442537; 0.813592045; 0.791234153; 0.768357994; 0.744306568; 0.719094568; 0.692488019; 0.66411648; 0.634292184; 0.602498593; 0.569711546; 0.534931653]
Here is Potcap if it helps.
Rex Mantiri
Rex Mantiri on 11 Dec 2021
Edited: Rex Mantiri on 11 Dec 2021
The added 'real' type was from when I ran a manual least squares and it gave 15 complex parameters. But after I changed it to real it ran for 26 hours and ended with:
Warning: Unable to find explicit solution. For options, see help.
> In sym/solve (line 317)
That's why I am currently trying to use the built-in MATLAB tools but I'm having no luck here too. Would it help if I gave the code that I used to determine the function Pot?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 11 Dec 2021
I am encountering an oddity. When I execute this code on my system, I do not get the "badly scaled", and I get a much better outcome. Furthermore if I restrict the number of iterations to (say) 2000 here then I get a much better outcome than what you see below.
The outcome I get on my system is
2.78592627618734
2.88871084081361
2.25105403422586
0.461395545224784
29.1302865591129
8.13171865752827
6.46299460979685
8.57614086623395
0.907578785962305
0.914773654903989
0.0722664894980859
0.00683972729472146
5.20591012847305e-05
0.00606806920191916
241.694759335038
for an fval of about 0.014.
I will follow up with Mathworks as to why I get such different answers here.
format long g
Potcap = [0.986702168; 0.97272091; 0.957930961; 0.942424001; 0.926404439; 0.909375829; 0.891635315; 0.873329497; 0.854253377; 0.834442537; 0.813592045; 0.791234153; 0.768357994; 0.744306568; 0.719094568; 0.692488019; 0.66411648; 0.634292184; 0.602498593; 0.569711546; 0.534931653];
t = [1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21];
x0 = [0.2;0.21;0.22;0.23;0.24;0.31;0.32;0.33;0.34;0.1;0.1;0.1;0.1;0.1;0.3];
lb = zeros(15,1);
ub = [Inf Inf Inf Inf Inf Inf Inf Inf Inf 1 1 1 1 1 Inf];
fnc = @(x) Fungsi(x,t,Potcap);
options = optimoptions(@fmincon);
options.MaxFunctionEvaluations = 1e4;
disp(options)
fmincon options: Options used by current Algorithm ('interior-point'): (Other available algorithms: 'active-set', 'sqp', 'sqp-legacy', 'trust-region-reflective') Set properties: MaxFunctionEvaluations: 10000 Default properties: Algorithm: 'interior-point' BarrierParamUpdate: 'monotone' CheckGradients: 0 ConstraintTolerance: 1e-06 Display: 'final' EnableFeasibilityMode: 0 FiniteDifferenceStepSize: 'sqrt(eps)' FiniteDifferenceType: 'forward' HessianApproximation: 'bfgs' HessianFcn: [] HessianMultiplyFcn: [] HonorBounds: 1 MaxIterations: 1000 ObjectiveLimit: -1e+20 OptimalityTolerance: 1e-06 OutputFcn: [] PlotFcn: [] ScaleProblem: 0 SpecifyConstraintGradient: 0 SpecifyObjectiveGradient: 0 StepTolerance: 1e-10 SubproblemAlgorithm: 'factorization' TypicalX: 'ones(numberOfVariables,1)' UseParallel: 0 Options not used by current Algorithm ('interior-point') Default properties: FunctionTolerance: 1e-06
[p, fval, exitflag, output] = fmincon(fnc, x0, [], [], [], [], lb, ub, @mycon, options);
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 6.518313e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 7.990654e-17.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.044527e-17.
Feasible point with lower objective function value found. Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
disp(p)
19638.238524254 19879.1047251019 17226.6281214069 6363.00448650999 215165.60981511 80103.5734866678 27605.4267163278 51439.4275828874 20707.9005623102 0.207884499264917 0.180524926831855 0.323597918952247 0.0540865744444137 0.233906080506567 1156659.1631545
disp(fval)
0.385262205496534
disp(exitflag)
2
disp(output)
iterations: 225 funcCount: 3747 constrviolation: 0 stepsize: 1.01709150638417e-10 algorithm: 'interior-point' firstorderopt: 0.0135635181978782 cgiterations: 498 message: '↵Local minimum possible. Constraints satisfied.↵↵fmincon stopped because the size of the current step is less than↵the value of the step size tolerance and constraints are ↵satisfied to within the value of the constraint tolerance.↵↵<stopping criteria details>↵↵Optimization stopped because the relative changes in all elements of x are↵less than options.StepTolerance = 1.000000e-10, and the relative maximum constraint↵violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.↵↵' bestfeasible: [1×1 struct]
function f = Fungsi(x, t, Potcap)
f = sum(((x(14)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)) + x(14)*(exp(-(t.*log(x(3)*x(15) + 1))/x(15)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/(x(2) - x(3)) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(3))*(x(2) - x(3)))) + x(14)*(exp(-(t.*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/(x(3) - x(4)) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) - x(13)*(exp(-(t.*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) + x(14)*(exp(-(t.*log(x(2)*x(15) + 1))/x(15)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/(x(1) - x(2))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4))*(x(3) - x(5)))/(x(8)*x(9)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(3))*(x(2) - x(3)))) - x(13)*((exp(-(t.*log(x(4)*x(15) + 1))/x(15))*(x(4) - x(5)))/x(9) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/(x(9)*(x(3) - x(4))) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4)))/(x(4) - x(5)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) + x(14)*(exp(-(t.*log(x(5)*x(15) + 1))/x(15)) + (x(9)*exp(-(t.*log(x(4)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(8)*x(9)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(7)*x(8)*x(9)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*x(9)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(5))*(x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(13)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/x(9) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(2)))) + x(12)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(2)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4))*(x(2) - x(5)))/(x(7)*x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)*(x(1) - x(2)))) - x(13)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(3))*(x(2) - x(3)))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) - (x(13)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/x(9) + (x(12)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) - (x(11)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(6)*x(7)*x(8)*x(9)))-Potcap).^2);
end
function [c,ceq] = mycon(x)
c = [];
ceq = (x(10)+x(11)+x(12)+x(13)+x(14))-1;
end
  33 Comments
Alex Sha
Alex Sha on 3 Feb 2022
The results below will be better, with the objective function value of 0.000142097015164559
x1 0.552962927693926
x2 7.0900791512254E-10
x3 79.4908429668269
x4 75.943703855999
x5 67.2161454152123
x6 21.3367020418602
x7 5.57437809140671
x8 399.606836671397
x9 38.5601160433331
x10 0.246017494458757
x11 0.00224637052140115
x12 0.122818175986558
x13 0.553876775143463
x14 0.0750411838898768
x15 1055.99540182052

Sign in to comment.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!