Is it possible to include a 'for loop' in a constraint file for optimization using fmincon solver?
Mostrar comentarios más antiguos
I am solving a multiperiod optimization problem using fmincon solver.Some of the constraints are non linear.The constraints are to be repeated for all periods.Is it possible to repeat the constraints for all periods by including a for loop in the mfile for constraints?
4 comentarios
Alan Weiss
el 5 de Feb. de 2018
I am afraid that I do not understand your question. A nonlinear constraint function is a MATLAB function. It can have any valid MATLAB commands, including if, while, for, or anything else.
But I think that is not really what you are asking. So can you please rephrase?
Alan Weiss
MATLAB mathematical toolbox documentation
Sukanya J Nair
el 6 de Feb. de 2018
Walter Roberson
el 6 de Feb. de 2018
for i = 1:12; ceq(i) = P(i)-a*h(i)*s(i); end
However it would make more sense to vectorize:
ceq = P - a .* h .* s;
Sukanya J Nair
el 6 de Feb. de 2018
Respuestas (0)
Categorías
Más información sobre Solver Outputs and Iterative Display 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!