18 using namespace Couenne;
25 std::ofstream
f (fname.c_str ());
27 f << std::setprecision (10);
31 f <<
"# Problem name: " << fname << std::endl << std::endl
32 <<
"# original variables" << std::endl << std::endl;
34 for (
int i=0; i <
nVars (); i++) {
42 f <<
" default " <<
X (i);
43 f <<
';' << std::endl;
81 f << std::endl <<
"# objective" << std::endl << std::endl;
89 f <<
';' << std::endl;
96 f << std::endl <<
"# aux. variables defined" << std::endl << std::endl;
98 for (
int i=0; i <
nVars (); i++)
107 f <<
';' << std::endl;
114 f << std::endl <<
"# constraints" << std::endl << std::endl;
117 for (std::vector <exprVar *>::iterator i =
variables_.begin ();
121 if (((*i) -> Type () ==
AUX) &&
122 ((*i) -> Multiplicity () > 0)) {
127 f <<
"conAuxLb" << (*i) -> Index () <<
": ";
129 f <<
">= " << bound <<
';' << std::endl;
133 f <<
"conAuxUb" << (*i) -> Index () <<
": ";
135 f <<
"<= " << bound <<
';' << std::endl;
140 for (
int i=0; i <
nCons (); i++) {
146 f <<
"con" << i <<
": ";
153 f << "= " << lb << ';
' << std::endl;
155 else f << " <= " << ub << ';
' << std::endl;
157 // if range constraint, print it once again
159 if (( lb > - COUENNE_INFINITY + 1)
160 && (ub < COUENNE_INFINITY - 1)
161 && (fabs (ub-lb) > COUENNE_EPS)) {
163 f << "con" << i << "_rng: ";
164 constraints_ [i] -> Body () -> print (f, !aux);
165 f << " <= " << ub << ';
' << std::endl;
int nVars() const
Total number of variables.
std::vector< CouenneObjective * > objectives_
Objectives.
void print(std::ostream &=std::cout)
Display current representation of problem: objective, linear and nonlinear constraints, and auxiliary variables.
void fint fint fint real fint real real real real * f
std::vector< CouenneConstraint * > constraints_
Constraints.
std::vector< exprVar * > variables_
Variables (original, auxiliary, and defined)
CouNumber * Ub() const
Return vector of upper bounds.
double CouNumber
main number type in Couenne
CouNumber * X() const
Return vector of variables.
int nCons() const
Get number of constraints.
void writeAMPL(const std::string &fname, bool aux)
Write nonlinear problem to a .mod file (with lots of defined variables)
CouNumber * Lb() const
Return vector of lower bounds.
bool isInteger(CouNumber x)
is this number integer?