14 #include "CoinHelperFunctions.hpp"
21 using namespace Couenne;
26 out <<
"objectives:" << std::endl;
27 for (std::vector <CouenneObjective *>::iterator i =
objectives_.begin ();
31 out <<
"constraints:" << std::endl;
32 for (std::vector <CouenneConstraint *>::iterator i =
constraints_.begin ();
36 out <<
"variables:" << std::endl;
37 for (std::vector <exprVar *>::iterator i =
variables_.begin ();
40 if (((*i) -> Type () !=
AUX) ||
41 ((*i) -> Multiplicity () > 0) ||
46 if (((*i) -> Type () ==
AUX) &&
47 (((*i) -> Multiplicity () > 0) ||
50 out <<
" (r:" << (*i) -> rank ()
51 <<
", m:" << (*i) -> Multiplicity () <<
") "
58 (*i) -> Image () ->
print (out,
false);
75 if ((*i) ->
isInteger ()) out <<
" integer";
82 out <<
"common expressions:" << std::endl;
83 for (std::vector <expression *>::iterator i =
commonexprs_.begin ();
93 out <<
"best known solution: (" << *
optimum_;
94 for (
int i=1; i <
nVars (); i++)
95 out <<
' ' << optimum_ [i];
96 out <<
')' << std::endl;
100 out <<
"best known objective: " <<
bestObj_ << std::endl;
102 out <<
"end" << std::endl;
115 int base = fname -> rfind (
'/'), size;
116 if (base < 0) base = 0;
else base++;
118 size = fname -> find (
'.', base) - base;
120 char *filename =
new char [size+5];
121 CoinFillN (filename, size+5, (
char) 0);
122 fname -> copy (filename, 1+size, base);
123 strcat (filename,
"txt");
124 f = fopen (filename,
"r");
126 }
else f = fopen (fname -> c_str (),
"r");
128 if (!f)
return false;
135 if (fscanf (f,
"%lf", &
bestObj_) < 1) {
137 printf (
"Couenne: warning, could not read objective from file \"%s\"\n", fname -> c_str ());
143 if (fscanf (f,
"%lf",
optimum_ + i) < 1) {
145 printf (
"Couenne: warning, could not read optimal value of x_%d from file \"%s\"\n", i, fname -> c_str ());
int nVars() const
Total number of variables.
CouNumber & ub(register int index)
current upper bound
std::vector< CouenneObjective * > objectives_
Objectives.
CouNumber & lb(register int index)
current lower bound
std::string problemName_
problem name
void print(std::ostream &=std::cout)
Display current representation of problem: objective, linear and nonlinear constraints, and auxiliary variables.
CouNumber bestObj_
Best known objective function.
std::vector< expression * > commonexprs_
AMPL's common expressions (read from AMPL through structures cexps and cexps1)
void fint fint fint real fint real real real real * f
void getAuxs(CouNumber *) const
Get auxiliary variables from original variables.
CouNumber opt_window_
window around known optimum (for testing purposes)
std::vector< CouenneConstraint * > constraints_
Constraints.
const Ipopt::EJournalCategory J_REFORMULATE(Ipopt::J_USER7)
std::vector< exprVar * > variables_
Variables (original, auxiliary, and defined)
Domain domain_
current point and bounds;
CouNumber * Ub() const
Return vector of upper bounds.
CouNumber * optimum_
Best solution known to be loaded from file – for testing purposes.
double CouNumber
main number type in Couenne
int nOrigVars_
Number of original variables.
bool readOptimum(std::string *fname=NULL)
Read best known solution from file given in argument.
JnlstPtr jnlst_
SmartPointer to the Journalist.
CouNumber * Lb() const
Return vector of lower bounds.
bool isInteger(CouNumber x)
is this number integer?