7 #include <boost/program_options.hpp> 
   14 namespace po = boost::program_options;
 
   20 int main(
int argc, 
char **argv) {
 
   22   po::options_description desc(
 
   23       "Solving the randomly generated Graph Coloring Problem using QUBO++ Easy Solver");
 
   24   desc.add_options()(
"help,h", 
"produce help message")
 
   25      (
"nodes,n", po::value<uint32_t>()->default_value(100),
"set the number of nodes")
 
   26      (
"proximity,p", po::value<uint32_t>()->default_value(20),
"set the proximity of the nodes")
 
   27      (
"Circle,C",
"Set nodes are placed on a circle")
 
   28      (
"Delaunay,D",
"Use Delaunay triangulation to connect the nodes")
 
   29      (
"colors,c", po::value<uint32_t>()->default_value(4),
"set the number of colors to use")
 
   30      (
"time,t", po::value<uint32_t>()->default_value(10), 
"set time limit in seconds")
 
   31      (
"problem_seed,s", po::value<uint32_t>(), 
"set the random seed for the TSP map")
 
   32      (
"output,o", po::value<std::string>(), 
"set the output file (png, svg, etc) to save the TSP solution");
 
   37     po::store(po::parse_command_line(argc, argv, desc), vm);
 
   38   } 
catch (
const std::exception &e) {
 
   39     std::cout << 
"Wrong arguments. Please use -h/--help option to see the " 
   45   if (vm.count(
"help")) {
 
   46     std::cout << desc << std::endl;
 
   51   uint32_t node_count = vm[
"nodes"].as<uint32_t>();
 
   53   uint32_t time_limit = vm[
"time"].as<uint32_t>();
 
   55   uint32_t color_count = vm[
"colors"].as<uint32_t>();
 
   58   if (vm.count(
"problem_seed")) {
 
   64   std::cout << 
"Generating random graph with " << node_count << 
" nodes" 
   70   if (vm.count(
"Delaunay")) {
 
   77   std::cout << 
"Variables = " << model.
var_count()
 
   79             << 
" Quadratic Terms = " << model.
term_count(2) << std::endl;
 
   81   if (vm.count(
"easy_solver_seed")) {
 
   83         vm[
"easy_solver_seed"].as<uint32_t>());
 
   89   grb_model.set_time_limit(time_limit);
 
   90   auto sol = grb_model.optimize();
 
   94   graph_color_map.
print();
 
   96   if (vm.count(
"output") > 0) {
 
   97     std::cout << 
"Writing the solution to " << vm[
"output"].as<std::string>()
 
   99     graph_color_map.
draw(vm[
"output"].as<std::string>());
 
vindex_t var_count() const
 
size_t term_count(vindex_t deg) const
 
Class to store a graph with node coloring and related information.
 
void gen_proximity_edges(uint32_t proximity)
Create an edges between nodes that are close to each other.
 
void gen_delaunay_edges()
Create edges between nodes using the Delaunay triangulation.
 
void draw(const std::string &filename)
Draw the graph in a file.
 
void gen_random_map(uint32_t n, bool is_circle=false)
Generate a random map with n nodes.
 
void print()
Displays the histogram of the colors.
 
void set_color_histogram(const GraphColorQuadModel &model, const qbpp::Sol &sol)
Set the color histogram of the nodes.
 
Class to store the QUBO expression with variables for the Graph Coloring Problem.
 
static void set_seed(uint32_t seed=1)
 
Class to store a QUBO model using Gurobi Optimizer through QUBO++ library.
 
int main(int argc, char **argv)
Main function to generate a random map and solve the Graph Coloring Problem using the Gurobi Optimize...
 
QUBO++, a C++ library for generating expressions for binary and spin variables.
 
QUBO++ interface to call Gurobi Optimizer.
 
A miscellaneous library used for sample programs of the QUBO++ library.