Optimization with 1 equation with 3 variables
Mostrar comentarios más antiguos
Chemical Engineer here so my programming is not that good. I am wondering if there is a way to find the minimum of a variable, 'x'. There is only one equation, and I'd like to find the minumum of 'x' by optimizing 'y' and 'z.' I know that I could plug in numbers, but is there a way for Matlab to automatically do this for me? Thank you!
10 comentarios
Walter Roberson
el 12 de Abr. de 2019
What operations does the equation involve? Is it a simple multinomial, or does it involve exp() ? trig functions? Bessel functions?
Do you have the symbolic toolbox?
Victoria
el 12 de Abr. de 2019
Walter Roberson
el 12 de Abr. de 2019
for multinomial fminsearch is less likely to get caught in a local min than fmincon or fminunc is. However even fminsearch can get caught in local min by sufficiently steep multinomial.
For multinomial the more robust approach is the calculus based approach of solving for zeros of the derivative.
Victoria
el 13 de Abr. de 2019
Walter Roberson
el 13 de Abr. de 2019
fmincon needs a function handle, not a logical or symbolic expression.
initial = [1 1 1]; %for example
A = []; b = [];
Aeq = []; beq = [];
lb = [-inf 0 0]; ub = [inf 10 100];
fmincon(@myequation, initial, A, b, Aeq, beq, lb, ub)
Victoria
el 13 de Abr. de 2019
Walter Roberson
el 13 de Abr. de 2019
There are a number of things wrong with that code, but we do not need to run it.
Your R1 is linear in lw, and your lw is not bounded (-inf to +inf). Therefore the minimum of myfun will be when lw is -infinity (as long as P1 and D2 are real valued and D2 is not 0)
Also, your R1 is linear in P1, so the minimum would be when P1 is minimum.
Also, your R1 is inversely proportional to D2, so the minimum would be when D2 is maximum.
Victoria
el 13 de Abr. de 2019
Walter Roberson
el 13 de Abr. de 2019
Review your equation. R1 is linear in P1, so minimum would be when P1 is minimum. R1 is inversely proportional to D2, so the minimum would be when D2 is maximum. Together with your bounds, that already tells you D2 = 10 and P1 = 0 . And then your equation is linear in lw, so you can make the result infinitely negative by making lw infinitely negative.
If the goal were to permit lw to be negative but that the overall minima of the function has to be >= 0, then provided you are willing to approximate 0.149 as 149/1000 instead of the actual [0.1485, 0.1495) range that 0.149 actually represents, then there is an exact solution that works out as approximately -137.34 . If you impose a lower bound of 0 for lw, then the minimum of the function is when lw is 0, and the minima would be approximately 137.34, which would decrease if you permitted D2 to become larger.
Respuestas (0)
Categorías
Más información sobre Numeric Solvers en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!