Correct use of auxiliary variables

278 views
Skip to first unread message

Greg K

unread,
Aug 30, 2011, 3:46:15 PM8/30/11
to AMPL Modeling Language
Hi all,

I am looking for an advice on how to use auxiliary variables (or not
use them at all) to achieve fastest solution of the problem.
I have a very long and complex function, let's call it f(n,m)
I want to maximize sum (all n,m) f(n,m).

The problem (I think it is a problem) with this is that since just a
single f(n,m) is pretty huge, sum of all of them (that's thousands of
them) will make objective function enormous
To make objective function smaller I introduced an auxiliary variable
p(n,m) and created a constraint of the following form
s.t. p(n,m) = f(n,m) for all n,m
This had allowed me to minimize an objective function to
max sum(all n,m) p(n,m)

But by doing that I've created thousands of extra unnecessary
variables (that's p(n,m)) which I think might slow down the solution.
So my dilemma is. Is it better to have enormously large objective
function and less variables, or to have much smaller and cleaner
objective function but much more unnecessary variables?
Any other clever ways I can handle this?

Thanks,
Greg

Robert Fourer

unread,
Aug 31, 2011, 4:59:24 PM8/31/11
to am...@googlegroups.com
Usually it is better to put as much as possible into the objective function,
no matter how complicated it becomes, rather than to add constraints
defining the components of the objective function. Nonlinearity of the
objective function tends to be easier to handle than nonlinearity in the
constraints.

You can always try it both ways, though. Changing option substout from its
default of 0 to 1 will cause all the p[n,m] = ... equations to be
automatically substituted out, provided no bounds are specified in the "var"
statement that defines p. So you can compare that with substout 0 which
leaves the constraints in. Set option show_stats 1 to check that the
substitutions are proceeding as expected. If possible, start by
experimenting on a small version of the problem, then scale up until you
reach the size of interest.

Bob Fourer
4...@ampl.com

Reply all
Reply to author
Forward
0 new messages