: _scip(0), _n(n), _vars(n, vector<
SCIP_VAR*>(n)), _cons()
47ostringstream namebuf;
48 for(
size_ti = 0; i < _n; ++i )
50 for(
size_tj = 0; j < _n; ++j )
54namebuf <<
"x#"<< i <<
"#"<< j;
57 SCIP_CALL_EXC(
SCIPcreateVar(_scip, & var, namebuf.str().c_str(), 0.0, 1.0, 1.0,
SCIP_VARTYPE_BINARY,
TRUE,
FALSE,
NULL,
NULL,
NULL,
NULL,
NULL) );
69 for(
size_ti = 0; i < _n; ++i )
81 for(
size_tj = 0; j < _n; ++j )
88_cons.push_back(cons);
92 for(
size_tj = 0; j < _n; ++j )
96namebuf <<
"col_"<< j;
100 for(
size_ti = 0; i < _n; ++i )
104_cons.push_back(cons);
111 for(
size_tj = 0; j < _n; ++j )
115namebuf <<
"diag_col_down_"<< j;
119 for(
size_ti = 0; i < _n - j; ++i )
122_cons.push_back(cons);
126 for(
size_ti = 0; i < _n; ++i )
130namebuf<<
"diag_row_down_"<<i;
134 for(
size_tj = 0; j < _n - i; ++j )
137_cons.push_back(cons);
141 for(
size_tj = 0; j < _n; ++j )
145namebuf<<
"diag_col_up_"<<j;
149 for(
size_ti = 0; i < _n - j; ++i )
152_cons.push_back(cons);
156 for(
size_ti = 0; i < _n; ++i )
160namebuf<<
"diag_row_up"<<i;
164 for(
size_tj = 0; j < _n - i; ++j )
167_cons.push_back(cons);
177out <<
"solution for "<< _n <<
"-queens:"<< endl << endl;
182out <<
"no solution found"<< endl;
186 for(
size_ti = 0; i < _n; ++i )
188 for(
size_tj = 0; j < _n; ++j )
192 for(
size_tj = 0; j < _n; ++j )
203 for(
size_tj = 0; j < _n; ++j)
215 for(
size_ti = 0; i < _n; ++i )
217 for(
size_tj = 0; j < _n; ++j )
223 for( vector<SCIP_CONS *>::size_type i = 0; i < _cons.size(); ++i )
233std::cerr <<
"SCIP Error: "<< exp.
what() << std::endl;
exception handling class for SCIP
const char * what(void) const
returns the error message
~QueensSolver()
destructor this is the place to release the SCIP_VAR and SCIP_CONS pointers and to free the SCIP poin...
void solve(void)
solves the queens problem using SCIPsolve
QueensSolver(size_t n=8)
constructs the BP model for the n-queens problem
void disp(std::ostream &out=std::cout)
display the solution
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreate(SCIP **scip)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_RETCODE SCIPsolve(SCIP *scip)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
void SCIPmessagehdlrSetQuiet(SCIP_MESSAGEHDLR *messagehdlr, SCIP_Bool quiet)
public methods for message output
exception handling for SCIP
#define SCIP_CALL_EXC(x)
macro to call scip function with exception handling
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4