SCIP Doxygen Documentation
Loading...
Searching...
No Matches
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
29
main
(
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
}
SCIPException
exception handling class for SCIP
Definition
scip_exception.hpp:115
SCIPException::what
const char * what(void) const
returns the error message
Definition
scip_exception.hpp:140
SCIPException::getRetcode
SCIP_RETCODE getRetcode(void) const
get method for _retcode
Definition
scip_exception.hpp:147
scipexamples::QueensSolver
solver class for the n-queens problem
Definition
queens.hpp:35
scipexamples::QueensSolver::solve
void solve(void)
solves the queens problem using SCIPsolve
Definition
queens.cpp:244
scipexamples::QueensSolver::disp
void disp(std::ostream &out=std::cout)
display the solution
Definition
queens.cpp:173
scipexamples
Definition
queens.hpp:28
std
Definition
pqueue.h:38
queens.hpp
n-queens example
main
int main(int args, char **argv)
Definition
queens_main.cpp:29
scip_exception.hpp
exception handling for SCIP
examples
Queens
src
queens_main.cpp
© 2002-2025 by Zuse Institute Berlin (ZIB),
Imprint
Generated by
1.14.0