How to solve for the minimum of a complex function

8 ビュー (過去 30 日間)
Austin Rasbach
Austin Rasbach 2018 年 3 月 31 日
回答済み: Austin Rasbach 2018 年 4 月 2 日
Hello, I am trying to optimize my system by varying one parameter, r, which will change an intermediate variable, kg, and ultimately result my one unknown, Se. My goal is to find the value r, which will result in the smallest value of Se.
I tried simplifying my process by fixing "r" at a single value and solving my symbolic "eqn" for Se. However, the only real solution isn't correct. My plan was to then take this equation for "Se" and vary "r" and plot "r vs. Se" and see the minimum. But no luck.
It would be great if I could take "eqn" and find the derivate dSe/dr = 0. But the way the equation is complicated with the symbol and the natural log, I couldn't get this to work either.
% Fixed Parameters:
Z = 10;
alpha = 40;
delta = 0.5;
Xa = 40;
k = 7.57;
Q = 1000;
So = 500;
Se = 20;
H = 15.42;
% Optimization Variable, r
r = 3; % In reality this variables range will be from 0 <= r <= 5
% Intermediate Variable
Kg = 50 + (200/(1+r)^2);
% Equation with one unknown, Se
syms Se
eqn = (Kg*log((So + 2*Se)/(20*(1 + r))) + (So - Se)/(1 + r))*(Q*(1 + r))/(k*Xa*delta*alpha*Z*H);
solve(eqn, Se, 'Real', true);

採用された回答

Austin Rasbach
Austin Rasbach 2018 年 4 月 2 日
Thanks Walter, but I couldn't get this method to produce what I was looking for. Instead I: -
  1. Took my non-linear function with one unknown (as a symbol)
  2. Wrote a loop indexing the two variables which changed over my interval
  3. Evaluated my non-linear function at each index, solving for the unknown
  4. Hard coded the answer into a blank array
  5. Used the [M, I] = min() function to find the minimum (and thus the optimization point) within the array
  6. Graphed the values to show the trends
I'm sure it's not as sleek as some would do, nor is it what I was originally planning on doing. But it works.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 3 月 31 日
編集済み: Walter Roberson 2018 年 3 月 31 日
The value of Se that minimizes eqn is Se = -250/(1+eps) (that is, the first representable number greater than -250) where it approaches -inf . (At Se = -250 itself you get NaN.)
If you take solve(diff(eqn,Se),Se), which gives a solution in R2018a, then the value you get is for maximizing the Se that solves the equation, given r.

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by