[AMPL 25038] Which is more computationally efficient??

Dear all,
I have a question:
Which is more computationally efficient:
using computed variables
or
including the equivalent constraint in the formulation?

var A: B+C
vs
subject to A==B+C

Thank you!!
R

Usually it is preferred to write

var A = B + C;

because then the expression “B + C” is substituted for A; the solver does not see the variable A or the constraint “A = B + C”. However, there can be exceptions where the number of “defined variables” like A is very large. So if you are finding that AMPL is taking an especially long time to generate the problem, you may want to try the alternative,

var A;
subject to Adefn: A = B + C;

to see whether it is faster.

Your question has been moved to our new user forum at discuss.ampl.com, and a response has been posted there. To see the response, use this link:

https://discuss.ampl.com/t/ampl-25038-which-is-more-computationally-efficient/1080/2

To reply, click the red “Reply” button that follows the response. (Do not send an email reply to this message.)

Thanks !!

El El mié, 1 may 2024 a las 14:50, AMPL Google Group via AMPL Discourse <notifications@ampl.discoursemail.com> escribió: