Optimization Problem with Error using optim.prob​lemdef.Opt​imizationP​roblem/sol​ve

11 vues (au cours des 30 derniers jours)
Hi, I'm currrently working on creating an optimization problem that finds the maximum of an equation that has 3 constraints. My code is:
prob = optimproblem('ObjectiveSense','max');
x=optimvar('x',2,1);
prob.Objective = 1+(x(1))^2 * ((x(2)-1)^3) * (exp(-x(1)-x(2)));
cons1 = x(2) >= log(x(1));
cons2 = x(1) + x(2) <= 6;
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
show(prob);
sol=solve(prob);
sol.x;
I keep getting the same errors:
Error using optim.problemdef.OptimizationProblem/solve
SOLVE requires a non-empty initial point structure to solve a nonlinear problem.
Please let me know if you have any advice. Thanks!

Réponse acceptée

Matt J
Matt J le 1 Fév 2021
Since your problem only has two unknowns, you can do a surface plot of the objective to find a decent initial guess.
  4 commentaires
Jason Qian
Jason Qian le 1 Fév 2021
Thank you so much. That makes a lot more sense. I really appreciate all the help!
Matt J
Matt J le 1 Fév 2021
You're quite welcome, but please Accept-click the answer to indicate that it resolved your question.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Solver-Based Optimization Problem Setup dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by