my equation has 3 variables but i want to integrate with respect to only one variable ,so that i can optimize the ramaining two from the resulting equation

2 ビュー (過去 30 日間)
my equation(looks big) is as follows , which has three variables (d,e,t) I want to integrate with t from 0 to 2000 (by keeping d,e constant ) so that i can optimize those two using any optimization method . i used int(err,0,2000) command but gettting no result .so how to get past this error?
the eqaution at its basic term is in form 1483/(k-1) , where K=function(d,e,t)
err =
1483/(200*(0.99966444607127868948737159371376*d - 99966.44460712373256683349609375*d*(0.0000000061953699799058132798891540549135*exp(-0.031830333683444479980079178105257*t) + 0.000010273947474151098879779908656928*exp(-9.1132612523704400742108333588476*t) - 0.00000028014284413259036773946597520535*exp(-0.21190841394611541767881157660725*t)) + 15567.003559999167919158935546875*e*(0.0000000061953699799058132798891540549135*exp(-0.031830333683444479980079178105257*t) + 0.000010273947474151098879779908656928*exp(-9.1132612523704400742108333588476*t) - 0.00000028014284413259036773946597520535*exp(-0.21190841394611541767881157660725*t)) + 919819.0186288356781005859375*d*(0.00000019463729288918805472585749072323*exp(-0.031830333683444479980079178105257*t) + 0.0000011273623338164517199144754044937*exp(-9.1132612523704400742108333588476*t) - 0.0000013219996267057210898032693080495*exp(-0.21190841394611541767881157660725*t)) - 143208.7303999960422515869140625*e*(0.00000019463729288918805472585749072323*exp(-0.031830333683444479980079178105257*t) + 0.0000011273623338164517199144754044937*exp(-9.1132612523704400742108333588476*t) - 0.0000013219996267057210898032693080495*exp(-0.21190841394611541767881157660725*t)) - 79516.5081846714019775390625*d*(0.0000061148367096900205219789370403305*exp(-0.031830333683444479980079178105257*t) + 0.00000012370569685174297169805157636802*exp(-9.1132612523704400742108333588476*t) - 0.0000062385424065411129723734973140381*exp(-0.21190841394611541767881157660725*t)) + 6144.9373500002548098564147949219*e*(0.0000061148367096900205219789370403305*exp(-0.031830333683444479980079178105257*t) + 0.00000012370569685174297169805157636802*exp(-9.1132612523704400742108333588476*t) - 0.0000062385424065411129723734973140381*exp(-0.21190841394611541767881157660725*t)) - 1))

採用された回答

Alan Weiss
Alan Weiss 2021 年 7 月 27 日
This seems like a solution. Of course, I don't know what your real bounds are on d and e, so I just guessed.
Notice that I used ./ in the first line of the function myfun. That is because the integral function requires vectorized inputs.
lb = [1/2 1/2];
ub = [3/4 3/4];
[sol,fval,eflag,output] = fmincon(@minfn,[1/2 1/2],[],[],[],[],lb,ub)
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
sol = 1×2
0.7500 0.7500
fval = -5.8613e+04
eflag = 1
output = struct with fields:
iterations: 4 funcCount: 15 constrviolation: 0 stepsize: 2.2605e-04 algorithm: 'interior-point' firstorderopt: 0.0757 cgiterations: 0 message: '↵Local minimum found that satisfies the constraints.↵↵Optimization completed because the objective function is non-decreasing in ↵feasible directions, to within the value of the optimality tolerance,↵and constraints are satisfied to within the value of the constraint tolerance.↵↵<stopping criteria details>↵↵Optimization completed: The relative first-order optimality measure, 3.264963e-07,↵is less than options.OptimalityTolerance = 1.000000e-06, and the relative maximum constraint↵violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.↵↵' bestfeasible: [1×1 struct]
function minit = minfn(x)
d = x(1);
e = x(2);
minit = intval(d,e);
end
function r = intval(d,e)
r = integral(@(t)myfun(d,e,t),0,2000);
end
function val = myfun(d,e,t)
val = 1483./(200*(0.99966444607127868948737159371376*d - ...
99966.44460712373256683349609375*d*(0.0000000061953699799058132798891540549135*exp(-0.031830333683444479980079178105257*t) +...
0.000010273947474151098879779908656928*exp(-9.1132612523704400742108333588476*t) -...
0.00000028014284413259036773946597520535*exp(-0.21190841394611541767881157660725*t)) + ...
15567.003559999167919158935546875*e*(0.0000000061953699799058132798891540549135*exp(-0.031830333683444479980079178105257*t) +...
0.000010273947474151098879779908656928*exp(-9.1132612523704400742108333588476*t) -...
0.00000028014284413259036773946597520535*exp(-0.21190841394611541767881157660725*t)) +...
919819.0186288356781005859375*d*(0.00000019463729288918805472585749072323*exp(-0.031830333683444479980079178105257*t) +...
0.0000011273623338164517199144754044937*exp(-9.1132612523704400742108333588476*t) -...
0.0000013219996267057210898032693080495*exp(-0.21190841394611541767881157660725*t)) -...
143208.7303999960422515869140625*e*(0.00000019463729288918805472585749072323*exp(-0.031830333683444479980079178105257*t) +...
0.0000011273623338164517199144754044937*exp(-9.1132612523704400742108333588476*t) -...
0.0000013219996267057210898032693080495*exp(-0.21190841394611541767881157660725*t)) -...
79516.5081846714019775390625*d*(0.0000061148367096900205219789370403305*exp(-0.031830333683444479980079178105257*t) +...
0.00000012370569685174297169805157636802*exp(-9.1132612523704400742108333588476*t) -...
0.0000062385424065411129723734973140381*exp(-0.21190841394611541767881157660725*t)) +...
6144.9373500002548098564147949219*e*(0.0000061148367096900205219789370403305*exp(-0.031830333683444479980079178105257*t) +...
0.00000012370569685174297169805157636802*exp(-9.1132612523704400742108333588476*t) -...
0.0000062385424065411129723734973140381*exp(-0.21190841394611541767881157660725*t)) - 1));
end
Alan Weiss
MATLAB mathematical toolbox documentation
  1 件のコメント
bhanu kiran vandrangi
bhanu kiran vandrangi 2021 年 7 月 27 日
thank you for the solution
i want the equation after integration so that i can use that as a cost function in particleswarm command(PSO) with 0,1 as bounds for bothd,e

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by