How to solve for the minimum of a complex function

14 views (last 30 days)
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);

Accepted Answer

Austin Rasbach
Austin Rasbach on 2 Apr 2018
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.

More Answers (1)

Walter Roberson
Walter Roberson on 31 Mar 2018
Edited: Walter Roberson on 31 Mar 2018
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.

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!