Scippy

SCIP

Solving Constraint Integer Programs

queens_main.cpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the examples to */
4 /* An introduction to SCIP */
5 /* */
6 /* Copyright (C) 2007 Cornelius Schwarz */
7 /* */
8 /* 2007 University of Bayreuth */
9 /* */
10 /* */
11 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12 
13 /**@file queens_main.cpp
14  * @brief main file for the queens example
15  * @author Cornelius Schwarz
16  */
17 
18 #include "queens.hpp"
19 #include <cstdlib>
20 #include <iostream>
21 #include "scip_exception.hpp"
22 
23 using namespace std;
24 using namespace scipexamples;
25 
26 
27 /** main function for queens example */
28 int
30  int args,
31  char ** argv
32  )
33 {
34  cout << "********************************************" << endl;
35  cout << "* n-queens solver based on SCIP *" << endl;
36  cout << "* *" << endl;
37  cout << "* (c) Cornelius Schwarz (2007) *" << endl;
38  cout << "********************************************" << endl << endl;
39 
40  if (args < 2)
41  {
42  cerr << "call " << argv[0] << " <number of queens>" << endl;
43  exit(1);
44  }
45 
46  // get the number of queens for commandline
47  size_t n = abs(atoi(argv[1])); /*lint !e732*/
48 
49  try
50  {
51  // initialize the queens solver
52  QueensSolver solver(n);
53 
54  // solve the queens problem
55  solver.solve();
56 
57  // display the solution on stdout
58  solver.disp();
59 
60  } catch(const SCIPException& exc)
61  {
62  cerr << exc.what() << endl;
63  exit((int) exc.getRetcode());
64  }
65  return EXIT_SUCCESS;
66 }
int main(int args, char **argv)
Definition: queens_main.cpp:29
void solve(void)
solves the queens problem using SCIPsolve
Definition: queens.cpp:231
exception handling for SCIP
SCIPInterval abs(const SCIPInterval &x)
void disp(std::ostream &out=std::cout)
display the solution
Definition: queens.cpp:173
exception handling class for SCIP
Definition: pqueue.h:28
SCIP_RETCODE getRetcode(void) const
get method for _retcode
const char * what(void) const
returns the error message
n-queens example
solver class for the n-queens problem
Definition: queens.hpp:34