Loading...
Searching...
No Matches
CglClique.hpp
Go to the documentation of this file.
// $Id$
// Copyright (C) 2000, International Business Machines
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
#ifndef _CglClique_h_
#define _CglClique_h_
#include "CglCutGenerator.hpp"
//class OsiCuts;
//class OsiSolverInterface;
class CglClique : public CglCutGenerator {
friend void CglCliqueUnitTest(const OsiSolverInterface * siP,
const std::string mpdDir );
public:
CglClique(const CglClique& rhs);
virtual CglCutGenerator * clone() const;
CglClique& operator=(const CglClique& rhs);
public:
virtual void
generateCuts(const OsiSolverInterface& si, OsiCuts & cs,
const CglTreeInfo info = CglTreeInfo());
CglClique(bool setPacking = false, bool justOriginalRows = false);
virtual ~CglClique() {}
virtual std::string generateCpp( FILE * fp);
void considerRows(const int numRows, const int* rowInd);
public:
enum scl_next_node_method {
SCL_MIN_DEGREE,
SCL_MAX_DEGREE,
SCL_MAX_XJ_MAX_DEG
};
void setStarCliqueNextNodeMethod(scl_next_node_method method) {
scl_next_node_rule = method;
}
void setStarCliqueCandidateLengthThreshold(int maxlen) {
scl_candidate_length_threshold = maxlen;
}
void setRowCliqueCandidateLengthThreshold(int maxlen) {
rcl_candidate_length_threshold = maxlen;
}
void setStarCliqueReport(bool yesno = true) { scl_report_result = yesno; }
void setRowCliqueReport(bool yesno = true) { rcl_report_result = yesno; }
void setDoStarClique(bool yesno = true) { do_star_clique = yesno; }
void setDoRowClique(bool yesno = true) { do_row_clique = yesno; }
void setMinViolation(double minviol) { petol = minviol; }
double getMinViolation() const { return petol; }
inline void setMaxNumber(int value) { maxNumber_ = value; }
private:
struct frac_graph ;
friend struct frac_graph ;
struct fnode {
int *nbrs;
double *edgecosts;
int degree;
double val;
};
struct frac_graph {
int nodenum;
int edgenum;
double density;
int min_deg_node;
int min_degree;
int max_deg_node;
int max_degree;
fnode *nodes;
int *all_nbr;
double *all_edgecost;
frac_graph() :
nodenum(0), edgenum(0), density(0),
min_deg_node(0), min_degree(0), max_deg_node(0), max_degree(0),
nodes(0), all_nbr(0), all_edgecost(0) {}
};
protected:
bool setPacking_;
bool justOriginalRows_;
int sp_numrows;
int* sp_orig_row_ind;
int sp_numcols;
int* sp_orig_col_ind;
double* sp_colsol;
int* sp_col_start;
int* sp_col_ind;
int* sp_row_start;
int* sp_row_ind;
frac_graph fgraph;
bool* node_node;
double petol;
int maxNumber_;
bool do_row_clique;
bool do_star_clique;
scl_next_node_method scl_next_node_rule;
int scl_candidate_length_threshold;
bool scl_report_result;
int rcl_candidate_length_threshold;
bool rcl_report_result;
const int* cl_perm_indices;
int cl_perm_length;
int* cl_indices;
int cl_length;
int* cl_del_indices;
int cl_del_length;
private:
void selectFractionalBinaries(const OsiSolverInterface& si);
void selectFractionals(const OsiSolverInterface& si);
void selectRowCliques(const OsiSolverInterface& si,int numOriginalRows);
void createSetPackingSubMatrix(const OsiSolverInterface& si);
void createFractionalGraph();
int createNodeNode();
void deleteSetPackingSubMatrix();
void deleteFractionalGraph();
void find_scl(OsiCuts& cs);
void find_rcl(OsiCuts& cs);
int scl_choose_next_node(const int current_nodenum,
const int *current_indices,
const int *current_degrees,
const double *current_values);
void scl_delete_node(const int del_ind, int& current_nodenum,
int *current_indices, int *current_degrees,
double *current_values);
int enumerate_maximal_cliques(int& pos, bool* scl_label, OsiCuts& cs);
int greedy_maximal_clique(OsiCuts& cs);
void recordClique(const int len, int* indices, OsiCuts& cs);
};
//#############################################################################
void CglCliqueUnitTest(const OsiSolverInterface * siP,
const std::string mpdDir);
class CglProbing;
class CglFakeClique : public CglClique {
public:
CglFakeClique(const CglFakeClique& rhs);
virtual CglCutGenerator * clone() const;
CglFakeClique& operator=(const CglFakeClique& rhs);
virtual void
generateCuts(const OsiSolverInterface& si, OsiCuts & cs,
const CglTreeInfo info = CglTreeInfo());
CglFakeClique(OsiSolverInterface * solver=NULL,bool setPacking = false);
virtual ~CglFakeClique();
void assignSolver(OsiSolverInterface * fakeSolver);
protected:
OsiSolverInterface * fakeSolver_;
CglProbing * probing_;
};
#endif
CglCliqueUnitTest
void CglCliqueUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglClique class.
CglCutGenerator.hpp
CglClique::cl_del_indices
int * cl_del_indices
An array of nodes discarded from the candidate list.
Definition CglClique.hpp:211
CglClique::selectFractionals
void selectFractionals(const OsiSolverInterface &si)
Scan through the variables and select those that are at a fractional level.
CglClique::rcl_candidate_length_threshold
int rcl_candidate_length_threshold
In the row clique method the maximal length of the candidate list (those nodes that can extend the ro...
Definition CglClique.hpp:188
CglClique::enumerate_maximal_cliques
int enumerate_maximal_cliques(int &pos, bool *scl_label, OsiCuts &cs)
CglClique::CglClique
CglClique(bool setPacking=false, bool justOriginalRows=false)
Default constructor.
CglClique::setDoStarClique
void setDoStarClique(bool yesno=true)
Definition CglClique.hpp:84
CglClique::deleteSetPackingSubMatrix
void deleteSetPackingSubMatrix()
CglClique::setStarCliqueCandidateLengthThreshold
void setStarCliqueCandidateLengthThreshold(int maxlen)
Definition CglClique.hpp:74
CglClique::sp_col_start
int * sp_col_start
Definition CglClique.hpp:150
CglClique::scl_candidate_length_threshold
int scl_candidate_length_threshold
In the star clique method the maximal length of the candidate list (those nodes that are in a star,...
Definition CglClique.hpp:180
CglClique::setRowCliqueReport
void setRowCliqueReport(bool yesno=true)
Definition CglClique.hpp:82
CglClique::cl_length
int cl_length
The length of cl_indices.
Definition CglClique.hpp:206
CglClique::generateCpp
virtual std::string generateCpp(FILE *fp)
Create C++ lines to get to current state.
CglClique::maxNumber_
int maxNumber_
Maximum number of binaries for looking at all.
Definition CglClique.hpp:163
CglClique::cl_perm_indices
const int * cl_perm_indices
variables/arrays that are used across many methods
Definition CglClique.hpp:198
CglClique::setDoRowClique
void setDoRowClique(bool yesno=true)
Definition CglClique.hpp:85
CglClique::justOriginalRows_
bool justOriginalRows_
True if just look at original rows.
Definition CglClique.hpp:143
CglClique::sp_numrows
int sp_numrows
pieces of the set packing part of the solverinterface
Definition CglClique.hpp:145
CglClique::operator=
CglClique & operator=(const CglClique &rhs)
Assignment operator.
CglClique::selectRowCliques
void selectRowCliques(const OsiSolverInterface &si, int numOriginalRows)
CglClique::considerRows
void considerRows(const int numRows, const int *rowInd)
CglClique::scl_choose_next_node
int scl_choose_next_node(const int current_nodenum, const int *current_indices, const int *current_degrees, const double *current_values)
CglClique::setStarCliqueNextNodeMethod
void setStarCliqueNextNodeMethod(scl_next_node_method method)
Definition CglClique.hpp:70
CglClique::deleteFractionalGraph
void deleteFractionalGraph()
CglClique::~CglClique
virtual ~CglClique()
Destructor.
Definition CglClique.hpp:55
CglClique::CglClique
CglClique(const CglClique &rhs)
Copy constructor.
CglClique::recordClique
void recordClique(const int len, int *indices, OsiCuts &cs)
CglClique::sp_row_start
int * sp_row_start
Definition CglClique.hpp:152
CglClique::cl_perm_length
int cl_perm_length
The length of cl_perm_indices.
Definition CglClique.hpp:200
CglClique::createNodeNode
int createNodeNode()
CglClique::scl_next_node_method
scl_next_node_method
possible choices for selecting the next node in the star clique search
Definition CglClique.hpp:64
CglClique::SCL_MAX_DEGREE
@ SCL_MAX_DEGREE
Definition CglClique.hpp:66
CglClique::SCL_MAX_XJ_MAX_DEG
@ SCL_MAX_XJ_MAX_DEG
Definition CglClique.hpp:67
CglClique::SCL_MIN_DEGREE
@ SCL_MIN_DEGREE
Definition CglClique.hpp:65
CglClique::setMaxNumber
void setMaxNumber(int value)
Maximum number of binaries for looking at all.
Definition CglClique.hpp:90
CglClique::sp_col_ind
int * sp_col_ind
Definition CglClique.hpp:151
CglClique::setMinViolation
void setMinViolation(double minviol)
Definition CglClique.hpp:87
CglClique::fgraph
frac_graph fgraph
the intersection graph corresponding to the set packing problem
Definition CglClique.hpp:156
CglClique::clone
virtual CglCutGenerator * clone() const
Clone.
CglClique::node_node
bool * node_node
the node-node incidence matrix of the intersection graph.
Definition CglClique.hpp:158
CglClique::greedy_maximal_clique
int greedy_maximal_clique(OsiCuts &cs)
CglClique::sp_orig_col_ind
int * sp_orig_col_ind
Definition CglClique.hpp:148
CglClique::setStarCliqueReport
void setStarCliqueReport(bool yesno=true)
Definition CglClique.hpp:81
CglClique::do_row_clique
bool do_row_clique
data for the star clique algorithm
Definition CglClique.hpp:170
CglClique::cl_indices
int * cl_indices
List of indices that should be considered for extending the ones listed in cl_perm_indices.
Definition CglClique.hpp:204
CglClique::getMinViolation
double getMinViolation() const
Definition CglClique.hpp:88
CglClique::selectFractionalBinaries
void selectFractionalBinaries(const OsiSolverInterface &si)
Scan through the variables and select those that are binary and are at a fractional level.
CglClique::sp_numcols
int sp_numcols
Definition CglClique.hpp:147
CglClique::find_scl
void find_scl(OsiCuts &cs)
CglClique::find_rcl
void find_rcl(OsiCuts &cs)
CglClique::createSetPackingSubMatrix
void createSetPackingSubMatrix(const OsiSolverInterface &si)
CglClique::scl_report_result
bool scl_report_result
whether to give a detailed statistics on the star clique method
Definition CglClique.hpp:182
CglClique::setRowCliqueCandidateLengthThreshold
void setRowCliqueCandidateLengthThreshold(int maxlen)
Definition CglClique.hpp:77
CglClique::setPacking_
bool setPacking_
An indicator showing whether the whole matrix in the solverinterface is a set packing problem or not.
Definition CglClique.hpp:141
CglClique::sp_colsol
double * sp_colsol
Definition CglClique.hpp:149
CglClique::createFractionalGraph
void createFractionalGraph()
CglClique::sp_row_ind
int * sp_row_ind
Definition CglClique.hpp:153
CglClique::CglCliqueUnitTest
friend void CglCliqueUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglClique class.
CglClique::frac_graph
friend struct frac_graph
Definition CglClique.hpp:95
CglClique::generateCuts
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate cuts for the model data contained in si.
CglClique::do_star_clique
bool do_star_clique
whether to do the star clique algorithm or not.
Definition CglClique.hpp:172
CglClique::scl_delete_node
void scl_delete_node(const int del_ind, int &current_nodenum, int *current_indices, int *current_degrees, double *current_values)
CglClique::cl_del_length
int cl_del_length
The length of cl_del_indices.
Definition CglClique.hpp:213
CglClique::rcl_report_result
bool rcl_report_result
whether to give a detailed statistics on the row clique method
Definition CglClique.hpp:190
CglClique::petol
double petol
The primal tolerance in the solverinterface.
Definition CglClique.hpp:161
CglClique::sp_orig_row_ind
int * sp_orig_row_ind
Definition CglClique.hpp:146
CglClique::scl_next_node_rule
scl_next_node_method scl_next_node_rule
How the next node to be added to the star clique should be selected.
Definition CglClique.hpp:175
CglCutGenerator::CglCutGenerator
CglCutGenerator()
Default constructor.
CglFakeClique::clone
virtual CglCutGenerator * clone() const
Clone.
CglFakeClique::CglFakeClique
CglFakeClique(OsiSolverInterface *solver=NULL, bool setPacking=false)
Default constructor.
CglFakeClique::generateCuts
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate cuts for the model data contained in si.
CglFakeClique::CglFakeClique
CglFakeClique(const CglFakeClique &rhs)
Copy constructor.
CglFakeClique::probing_
CglProbing * probing_
Probing object.
Definition CglClique.hpp:309
CglFakeClique::operator=
CglFakeClique & operator=(const CglFakeClique &rhs)
Assignment operator.
CglFakeClique::fakeSolver_
OsiSolverInterface * fakeSolver_
fake solver to use
Definition CglClique.hpp:307
CglFakeClique::~CglFakeClique
virtual ~CglFakeClique()
Destructor.
CglFakeClique::assignSolver
void assignSolver(OsiSolverInterface *fakeSolver)
Assign solver (generator takes over ownership).
CglProbing
Probing Cut Generator Class.
Definition CglProbing.hpp:25
CglTreeInfo
Information about where the cut generator is invoked from.
Definition CglTreeInfo.hpp:15
CglClique::fnode
A node of the fractional graph.
Definition CglClique.hpp:99
CglClique::fnode::degree
int degree
degree of the node
Definition CglClique.hpp:106
CglClique::fnode::nbrs
int * nbrs
pointer into all_nbr
Definition CglClique.hpp:101
CglClique::fnode::val
double val
the fractional value of the variable corresponding to this node
Definition CglClique.hpp:108
CglClique::fnode::edgecosts
double * edgecosts
1-x_i-x_j, needed for odd holes, in the same order as the adj list, pointer into all_edgecost
Definition CglClique.hpp:104
CglClique::frac_graph
A graph corresponding to a fractional solution of an LP.
Definition CglClique.hpp:113
CglClique::frac_graph::frac_graph
frac_graph()
Definition CglClique.hpp:132
CglClique::frac_graph::min_degree
int min_degree
Definition CglClique.hpp:121
CglClique::frac_graph::min_deg_node
int min_deg_node
Definition CglClique.hpp:120
CglClique::frac_graph::edgenum
int edgenum
Definition CglClique.hpp:117
CglClique::frac_graph::density
double density
density= edgenum/(nodenum choose 2)
Definition CglClique.hpp:119
CglClique::frac_graph::all_nbr
int * all_nbr
The array of all the neighbors.
Definition CglClique.hpp:128
CglClique::frac_graph::nodes
fnode * nodes
The array of the nodes in the graph.
Definition CglClique.hpp:125
CglClique::frac_graph::nodenum
int nodenum
Definition CglClique.hpp:115
CglClique::frac_graph::max_degree
int max_degree
Definition CglClique.hpp:123
CglClique::frac_graph::max_deg_node
int max_deg_node
Definition CglClique.hpp:122
CglClique::frac_graph::all_edgecost
double * all_edgecost
The array of the costs of the edges going to the neighbors.
Definition CglClique.hpp:130