solving this maximization problem

1 view (last 30 days)
Fatemeh
Fatemeh on 31 Jul 2024
Commented: Umar on 31 Jul 2024
Hi everyone,
Could anyone assist me with solving this maximization problem in MATLAB? I need to maximize the following function and determine the optimal values of r and t.
Thank you!
-(1/((1 + 2 a)^2))
t (-3 - 2 r + t - 5 a + 2 t a +
2 Sqrt[2 (2 + r - t) + (-2 + 2 r^2 + t)/(1 + a)] +
2 a Sqrt[
2 (2 + r - t) + (-2 + 2 r^2 + t)/(1 + a)]) (-4 r +
2 a (-2 + Sqrt[
2 (2 + r - t) + (-2 + 2 r^2 + t)/(1 + a)]) +
3 (-1 + Sqrt[2 (2 + r - t) + (-2 + 2 r^2 + t)/(1 + a)]))
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
  7 Comments
Torsten
Torsten on 31 Jul 2024
Maybe of help to get some critical points depending on a:
syms a
syms r t; % Define symbolic variables 'r' and 't'
f = -(1/((1 + 2*a)^2)) * t * (-3 - 2*r + t - 5*a + 2*t*a + 2*sqrt(2*(2 + r - t) + (-2 + 2*r^2 + t)/(1 + a)) + 2*a*sqrt(2*(2 + r - t) + (-2 + 2*r^2 + t)/(1 + a))) * (-4*r + 2*a*(-2 + sqrt(2*(2 + r - t) + (-2 + 2*r^2 + t)/(1 + a))) + 3*(-1 + sqrt(2*(2 + r - t) + (-2 + 2*r^2 + t)/(1 + a))))
f = 
dfdr = diff(f,r);
dfdt = diff(f,t);
sol = solve([dfdr,dfdt],[r,t])
Warning: Possibly spurious solutions.
sol = struct with fields:
r: [16x1 sym] t: [16x1 sym]
sol.r
ans = 
sol.t
ans = 
Umar
Umar on 31 Jul 2024
@Torsten & @Walter,
Thanks for your support, really appreciated.

Sign in to comment.

Answers (1)

Raghava S N
Raghava S N on 31 Jul 2024
Hi Fatemeh,
Optimization of an equation with a two variable function can be solved using MATLAB’s optimization toolbox. Please refer to the documentation page of the Optimization Toolbox here - https://www.mathworks.com/help/optim/getting-started-with-optimization-toolbox.html.
The workflow to optimize a nonlinear multivariable function is as follows:
Firstly, the equation that has to be optimized must be parameterized to use the Optimization Toolbox routines. The variables undergoing optimization should be the parameters. Please refer to this documentation page that describes how to parameterize functions and equations - https://www.mathworks.com/help/matlab/math/parameterizing-functions.html.
In the next step, the negated value of the parameterized equation should be passed to the function “fmincon”. This function finds the minimum of a constrained nonlinear multivariable function. So, by passing the negated value of the parameterized equation, the maximum is obtained. Please refer to the documentation of “fmincon” here - https://www.mathworks.com/help/optim/ug/fmincon.html
Please refer to two other MATLAB Answers posts that discuss the optimization of a function with two variables in detail. The links for the same are attached below:
Hope this helps!
Raghava

Community Treasure Hunt

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

Start Hunting!