Print initial value that solvers choose

Hello everyone.
I plan to set the initial values for the variables manually and not automatically. I used this method:

ampl::Variable xTarget = ampl -> getVariable("x2");
xTarget.setValue(13);

But I am not sure that exactly this value was chosen as the initial value. How can I get (or print) the initial values that solvers choose in AMPL? i use the AMPL C++ API.
Thank you.

1 Like

Your C++ statements are setting the value of variable xTarget to 13. When you call a solver, AMPL will send 13 to the solver as a suggested initial value for xTarget. If you set values of other variables, they will also be sent to the solver as suggested initial values for those variables. However, if you do not set any values for some of the variables, then AMPL will not send any suggested initial values for those variables.

It is possible to ask AMPL for a list of all the initial values that it is suggesting to the solver. If you need help getting that list, just ask for more help.

Each solver decides how to use AMPL’s suggested initial values, however. To get help with how AMPL’s suggested initial values are used, you will need to answer some more questions. For example,

  • What solver (or solvers) are you using?
  • Does your model have integer-valued variables?
  • Does your model have some kinds of expressions that are not linear?
1 Like