×
☰
Toggle navigation
SCIP Optimization Suite
SCIP
SoPlex
ZIMPL
UG
GCG
Documentation
SCIP 9.2.0
SCIP 8.1.0
SCIP 7.0.3
SCIP 6.0.2
SCIP 5.0.1
SCIP 4.0.1
SCIP 3.2.1
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
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
}
main
int main(int args, char **argv)
Definition:
queens_main.cpp:29
scipexamples::QueensSolver::solve
void solve(void)
solves the queens problem using SCIPsolve
Definition:
queens.cpp:244
scipexamples
Definition:
queens.hpp:27
scip_exception.hpp
exception handling for SCIP
abs
SCIPInterval abs(const SCIPInterval &x)
Definition:
intervalarithext.h:372
scipexamples::QueensSolver::disp
void disp(std::ostream &out=std::cout)
display the solution
Definition:
queens.cpp:173
SCIPException
exception handling class for SCIP
Definition:
scip_exception.hpp:114
std
Definition:
pqueue.h:28
SCIPException::getRetcode
SCIP_RETCODE getRetcode(void) const
get method for _retcode
Definition:
scip_exception.hpp:147
SCIPException::what
const char * what(void) const
returns the error message
Definition:
scip_exception.hpp:140
queens.hpp
n-queens example
scipexamples::QueensSolver
solver class for the n-queens problem
Definition:
queens.hpp:34