7 #ifndef CMR_DATAGROUP_H 8 #define CMR_DATAGROUP_H 25 #include <concorde/INCLUDE/util.h> 44 Instance(
int seed,
int ncount,
int gridsize);
47 Instance(
const std::string &probname,
int seed,
int ncount,
48 std::vector<int> &elist, std::vector<int> &elen,
int default_len);
50 Instance(
const std::string &probname,
int seed,
int ncount,
51 std::vector<int> &elist, std::vector<int> &elen)
52 :
Instance(probname, seed, ncount, elist, elen, 0) {}
61 CCdatagroup*
ptr()
const {
return const_cast<CCdatagroup*
>(&
dat); }
65 {
return CCutil_dat_edgelen(end0, end1,
ptr()); }
69 {
return [
this](
int e0,
int e1){
return edgelen(e0, e1); }; }
72 int seed()
const {
return random_seed; }
75 double tour_length(
const std::vector<int> &tour_nodes)
const;
112 CoreGraph(
int ncount,
int ecount,
const int *elist,
113 const std::function<
double(
int,
int)>
edgelen);
116 CoreGraph(
const std::vector<int> &tour_nodes,
117 const std::function<
double(
int,
int)>
edgelen);
120 int edge_count()
const {
return edges.size(); }
123 int find_edge_ind(
int end0,
int end1)
const;
125 Edge get_edge(
int index)
const {
return edges[index]; }
127 std::vector<Edge> &get_edges() {
return edges; }
128 const std::vector<Edge> &get_edges()
const {
return edges; }
130 const AdjList &get_adj()
const {
return adj_list; }
132 void add_edge(
int end0,
int end1,
int len);
133 void add_edge(
const Edge &e);
138 template<
typename numtype>
139 void tour_edge_vec(
const std::vector<int> &tour_nodes,
140 std::vector<numtype> &tour_edges,
141 double &tour_val)
const;
144 std::vector<Edge> edges;
162 const std::string &tourfile);
179 const std::vector<double> &lp_x,
180 std::vector<int> &island,
186 bool in_subtour_poly();
201 const std::string &tour_nodes_fname,
202 const std::string &lp_sol_fname,
205 std::vector<double> &lp_edges,
210 const std::string &tour_nodes_fname,
211 const std::string &lp_sol_fname,
214 std::vector<double> &lp_edges,
230 template<
typename numtype>
231 void CoreGraph::tour_edge_vec(
const std::vector<int> &tour_nodes,
232 std::vector<numtype> &tour_edges,
233 double &tour_val)
const 237 using std::runtime_error;
240 tour_edges.resize(edges.size());
241 std::fill(tour_edges.begin(), tour_edges.end(), 0);
244 int ncount = nodecount;
246 for (
int i = 0; i < ncount; ++i) {
247 EndPts e(tour_nodes[i], tour_nodes[(i + 1) % ncount]);
248 int ind = find_edge_ind(e.end[0], e.end[1]);
250 cerr << e <<
" not in CoreGraph" << endl;
251 throw runtime_error(
"Missing tour edge in CoreGraph");
254 tour_val += edges[ind].len;
Support graph data for an LP solution.
Definition: datagroups.hpp:174
std::vector< double > lp_vec
The LP solution vector.
Definition: datagroups.hpp:188
int node_count() const
Number of nodes.
Definition: datagroups.hpp:71
std::vector< double > support_ecap
Weights on nonzero entries.
Definition: datagroups.hpp:191
std::vector< int > best_tour_edges
Binary vector of tour edges.
Definition: datagroups.hpp:165
void make_cut_test(const std::string &tsp_fname, const std::string &tour_nodes_fname, const std::string &lp_sol_fname, Graph::CoreGraph &core_graph, Data::BestGroup &best_data, std::vector< double > &lp_edges, Data::SupportGroup &supp_data)
Load just enough data to test separation routines.
double edgelen(int end0, int end1) const
Edge length between two nodes in an Instance.
Definition: datagroups.hpp:64
Header for classes/structures/functions to work with graphs.
Information about the current best tour.
Definition: datagroups.hpp:154
std::vector< int > support_indices
Nonzero entries of lp_vec.
Definition: datagroups.hpp:189
CCdatagroup dat
The Concorde data structure being managed.
Definition: datagroups.hpp:81
bool connected
Is the graph connected.
Definition: datagroups.hpp:195
Instance() noexcept
Default construct an empty instance.
Definition: datagroups.cpp:48
int seed() const
Random seed used.
Definition: datagroups.hpp:72
Graph structures for the edges currently in a CoreLP::Relaxation.
Definition: datagroups.hpp:100
CoreGraph(const Data::Instance &inst)
Construct a CoreGraph as above with EdgePlan::Linkern edges.
Definition: datagroups.hpp:108
10 LK tours, with quadnearest for tiny instances.
const std::function< double(int, int)> edgelen_func() const
A function object for the edge length.
Definition: datagroups.hpp:68
Storing TSP instance data.
Definition: datagroups.hpp:36
Representing graph edges and costs.
Definition: graph.hpp:29
ERROR HANDLING CLASSES AND ROUTINES.
std::vector< int > support_elist
Node-node elist for nonzero entries.
Definition: datagroups.hpp:190
Utility functions, macros, and structures.
std::vector< int > perm
Defined by perm[best_tour_nodes[i]] = i.
Definition: datagroups.hpp:168
double min_tour_value
The tour length.
Definition: datagroups.hpp:170
CCdatagroup * ptr() const
Access the raw pointer to the data, for use by Concorde routines.
Definition: datagroups.hpp:61
bool integral
Is the solution vector integral.
Definition: datagroups.hpp:196
EdgePlan
Edge generation protocol to use.
Definition: datagroups.hpp:94
The namespace for this project.
Definition: abc_nodesel.hpp:20
Graph::AdjList supp_graph
Adjacency list rep of support graph.
Definition: datagroups.hpp:193
Representation of a graph as an adjacency list.
Definition: graph.hpp:80
Simple base class for storing edge of a graph as a sorted pair of nodes.
Definition: util.hpp:239
double tour_length(const std::vector< int > &tour_nodes) const
Get the length of the tour in tour_nodes.
Definition: datagroups.cpp:177
const std::string & problem_name() const
The TSPLIB instance name or the random problem dimensions.
Definition: datagroups.hpp:78
std::vector< int > best_tour_nodes
Sequence of nodes in the tour.
Definition: datagroups.hpp:167