15 using namespace Couenne;
31 void Node::node(
int i,
double c ,
double l,
double u,
int cod,
int s){
91 for (std::vector <exprVar *>:: iterator i =
Variables (). begin ();
94 if ((*i) -> Type () ==
AUX) {
99 if ((*i) -> Image () -> Type () ==
N_ARY) {
100 for (
int a=0; a < (*i) -> Image () -> nArgs(); a++) {
101 expression *arg = (*i) -> Image () -> ArgList () [
a];
103 if (arg -> Type () ==
CONST) {
115 if (e -> getc0 () != 0 ){
121 for (exprGroup::lincoeff::iterator el = e ->lcoeff().begin (); el != e -> lcoeff ().end (); ++el) {
122 if ( el -> second !=1){
132 int nc = num_affine +
nVars ();
139 int coef_count=
nVars ();
140 for (std::vector <exprVar *>:: iterator i =
Variables (). begin ();
145 if ((*i) -> Type () ==
AUX) {
150 vertex.
node( (*i) -> Index () , 0.0 , (*i) -> lb () , (*i) -> ub () , (*i) -> Image () -> code(), (*i)-> sign() );
156 if ((*i) -> Image () -> Type () ==
N_ARY) {
159 expression *arg = (*i) -> Image () -> ArgList () [0];
161 expression *arg2 = (*i) -> Image () -> ArgList () [1];
165 coef_vertex.
node( coef_count, -1, -1 ,-1, -2 , 0);
172 for (
int a=0; a < (*i) -> Image () -> nArgs(); a++) {
173 expression *arg = (*i) -> Image () -> ArgList () [
a];
175 if (arg -> Type () !=
CONST) {
183 assert (arg -> Type () ==
CONST);
192 coef_vertex.
node( coef_count, arg -> Value(), arg -> Value() , arg -> Value(), -2 , 0);
207 if (e -> getc0 () != 0 ){
209 coef_vertex.
node( coef_count, e -> getc0(), e -> getc0() , e -> getc0(), -2, 0 );
223 for (exprGroup::lincoeff::iterator el = e ->lcoeff().begin (); el != e -> lcoeff ().end (); ++el) {
225 if ( el -> second ==1){
233 coef_vertex.
node( coef_count, el -> second, el -> second, el -> second, -2, 0 );
253 else if ((*i) -> Image () -> Type () ==
UNARY) {
255 expression *arg = (*i) -> Image () -> Argument () ;
259 else if ((*i) -> Image () -> Type () ==
AUX) {
265 else if ((*i) -> Image () -> Type () ==
VAR) {
279 var_vertex.
node( (*i) -> Index () , 0 , 1 , 0 , -1, -1 );
284 var_vertex.
node( (*i) -> Index () , 0 , (*i) -> lb () , (*i) -> lb() -1 , -1, -1 );
289 var_vertex.
node( (*i) -> Index () , 0 , (*i) -> ub () +1 , (*i) -> ub () , -1, -1 );
294 var_vertex.
node( (*i) -> Index () , 0 , (*i) -> lb () , (*i) -> ub () , -1, -1 );
320 (*i).color_vertex(-1);
324 if( (*i).get_color() == -1){
325 (*i).color_vertex(color);
327 nauty_info -> color_node((*i).get_index(), color);
328 for (std::vector <Node>:: iterator
j = i+1;
j !=
node_info.
end (); ++
j)
330 (*j).color_vertex(color);
331 nauty_info -> color_node((*j).get_index(),color);
354 printf (
"Couenne: %d generators, group size: %.0g",
359 int nNonTrivialOrbits = 0;
361 for (
unsigned int i = 0; i < new_orbits -> size(); i++) {
362 if ((*new_orbits)[i].size() > 1)
373 printf (
" (%d non-trivial orbits).\n", nNonTrivialOrbits);
376 if (nNonTrivialOrbits) {
380 std::vector<std::vector<int> > *orbits =
nauty_info -> getOrbits ();
382 for (std::vector <std::vector<int> >::iterator i = orbits -> begin (); i != orbits ->
end (); ++i) {
384 printf (
"Orbit %d: ", orbCnt++);
386 for (std::vector<int>::iterator
j = i -> begin ();
j != i ->
end (); ++
j)
396 if (nNonTrivialOrbits)
397 for (
int i=0; i<
nVars (); i++) {
399 std::vector< int > *branch_orbit =
Find_Orbit (i);
401 if (branch_orbit -> size () > 1) {
402 printf (
"x%04d: ", i);
404 for (std::vector<int>::iterator it = branch_orbit -> begin (); it != branch_orbit ->
end (); ++it)
415 std::vector<int> *orbit =
new std::vector <int>;
416 int which_orbit = -1;
419 for (
unsigned int i = 0; i < new_orbits -> size(); i++) {
420 for (
unsigned int j = 0;
j < (*new_orbits)[i].size();
j++) {
422 if( (*new_orbits)[i][
j] == index)
428 for (
unsigned int j = 0;
j < (*new_orbits)[which_orbit].size();
j++)
429 orbit -> push_back ((*new_orbits)[which_orbit][
j]);
438 assert (num_cols ==
nVars ());
441 for (
int i = 0; i < num_cols; i++) {
445 node_info[i ].bounds ( new_lb[i] , new_ub[i] );
464 Couenne: Warning, you have set orbital_branching but Nauty is not available.\n\
465 Reconfigure with appropriate options --with-nauty-lib=/path/to/libnauty.* and --with-nauty-incdir=/path/to/nauty/include/files/\n");
int nVars() const
Total number of variables.
class Group, with constant, linear and nonlinear terms:
void addElement(int ix, int jx)
void fint fint fint real * a
void Print_Orbits() const
static int nSGcomputations
void fint fint fint real fint real real real real real real real real real * e
void setupSymmetry()
empty if no NTY, symmetry data structure setup otherwise
bool compare(register Node &a, register Node &b) const
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
std::vector< exprVar * > & Variables()
Return vector of variables (symbolic representation)
std::vector< Node > node_info
void ChangeBounds(const double *, const double *, int) const
bool orbitalBranching_
use orbital branching?
void Compute_Symmetry() const
void node(int, double, double, double, int, int)
JnlstPtr jnlst_
SmartPointer to the Journalist.
The in-memory representation of the variables element.
const Ipopt::EJournalCategory J_COUENNE(Ipopt::J_USER8)
std::vector< int > * Find_Orbit(int) const
std::vector< std::vector< int > > * getOrbits() const
Returns the orbits in a "convenient" form.