C++ GeCode包含被拒绝的权限
我是GeCode和libg++编译器的新手。。。遇到编译问题。环境和错误信息如下所示:C++ GeCode包含被拒绝的权限,c++,linux,gecode,C++,Linux,Gecode,我是GeCode和libg++编译器的新手。。。遇到编译问题。环境和错误信息如下所示: Environment: x86_64-linux GeCode version: gecode-4.2.0 in <../lib/gecode-4.2.0/> g++ version: 4.7.2 (Debian 4.7.2-5) 在../doc/目录下,我需要编译sendmory.cpp /* ------------------------------------------------
Environment: x86_64-linux
GeCode version: gecode-4.2.0 in <../lib/gecode-4.2.0/>
g++ version: 4.7.2 (Debian 4.7.2-5)
在../doc/目录下,我需要编译sendmory.cpp
/* ------------------------------------------------------------
Problem Description
-------------------
S E N D
+ M O R E
-------------
M O N E Y
------------------------------------------------------------ */
#include <ilsolver/ilosolverint.h>
ILOSTLBEGIN
int main() {
IloEnv env;
try {
IloModel model(env);
// Variables and Domains
IloIntVar S(env, 1, 9, "S"); IloIntVar M(env, 1, 9, "M");
IloIntVar E(env, 0, 9, "E"); IloIntVar O(env, 0, 9, "O");
IloIntVar N(env, 0, 9, "N"); IloIntVar R(env, 0, 9, "R");
IloIntVar D(env, 0, 9, "D"); IloIntVar Y(env, 0, 9, "Y");
// The SEND+MORE=MONEY constraint
IloExpr SEND(env), MORE(env), MONEY(env);
SEND = ( 1000*S + 100*E + 10*N + D );
MORE = ( 1000*M + 100*O + 10*R + E );
MONEY = ( 10000*M + 1000*O + 100*N + 10*E + Y );
IloConstraint puzzle;
puzzle = ( SEND + MORE == MONEY );
model.add(puzzle);
SEND.end(); MORE.end(); MONEY.end();
// !! Alternative: post the SEND+MORE=MONEY constraint directly
// model.add( 1000*S + 100*E + 10*N + D
// + 1000*M + 100*O + 10*R + E
// == 10000*M + 1000*O + 100*N + 10*E + Y );
// Use an array to collect the variables
IloInt numVars = 8;
IloIntVarArray vars( env, numVars );
vars[0] = S; vars[1] = E; vars[2] = N; vars[3] = D;
vars[4] = M; vars[5] = O; vars[6] = R; vars[7] = Y;
// The disequality constraints using double for loop
IloInt i,j;
for ( i=0; i < numVars - 1; i++ ) {
for ( j=i+1; j < numVars; j++ ) {
model.add( vars[i] != vars[j] );
} //endfor
} //endfor
// !! Alternative: a single all_different constraints
// model.add(IloAllDiff(env, vars));
// Pass the model to ILOG Solver
IloSolver solver(model);
if ( solver.solve() ) {
// Print the Solution
solver.out() << "Solution: ";
solver.out() << " S=" << (IloInt) solver.getValue(S);
solver.out() << " E=" << (IloInt) solver.getValue(E);
solver.out() << " N=" << (IloInt) solver.getValue(N);
solver.out() << " D=" << (IloInt) solver.getValue(D);
solver.out() << " M=" << (IloInt) solver.getValue(M);
solver.out() << " O=" << (IloInt) solver.getValue(O);
solver.out() << " R=" << (IloInt) solver.getValue(R);
solver.out() << " Y=" << (IloInt) solver.getValue(Y);
solver.out() << endl;
} // endif
} // endtry
catch (IloException& ex) {
cout << "Error: " << ex << endl;
} // endcatch
env.end();
return 0;
}
/*
Solution: S=9 E=5 N=6 D=7 M=1 O=0 R=8 Y=2
*/
有人能帮忙吗?谢谢。您的命令行中真的有这些吗?@Mat是的,我有。谢谢你的快速回复@Mat我也可以将内容粘贴到gecode目录下,希望能有所帮助。这些都是重定向。您要求shell将g++-I的输出写入/include。
/* ------------------------------------------------------------
Problem Description
-------------------
S E N D
+ M O R E
-------------
M O N E Y
------------------------------------------------------------ */
#include <ilsolver/ilosolverint.h>
ILOSTLBEGIN
int main() {
IloEnv env;
try {
IloModel model(env);
// Variables and Domains
IloIntVar S(env, 1, 9, "S"); IloIntVar M(env, 1, 9, "M");
IloIntVar E(env, 0, 9, "E"); IloIntVar O(env, 0, 9, "O");
IloIntVar N(env, 0, 9, "N"); IloIntVar R(env, 0, 9, "R");
IloIntVar D(env, 0, 9, "D"); IloIntVar Y(env, 0, 9, "Y");
// The SEND+MORE=MONEY constraint
IloExpr SEND(env), MORE(env), MONEY(env);
SEND = ( 1000*S + 100*E + 10*N + D );
MORE = ( 1000*M + 100*O + 10*R + E );
MONEY = ( 10000*M + 1000*O + 100*N + 10*E + Y );
IloConstraint puzzle;
puzzle = ( SEND + MORE == MONEY );
model.add(puzzle);
SEND.end(); MORE.end(); MONEY.end();
// !! Alternative: post the SEND+MORE=MONEY constraint directly
// model.add( 1000*S + 100*E + 10*N + D
// + 1000*M + 100*O + 10*R + E
// == 10000*M + 1000*O + 100*N + 10*E + Y );
// Use an array to collect the variables
IloInt numVars = 8;
IloIntVarArray vars( env, numVars );
vars[0] = S; vars[1] = E; vars[2] = N; vars[3] = D;
vars[4] = M; vars[5] = O; vars[6] = R; vars[7] = Y;
// The disequality constraints using double for loop
IloInt i,j;
for ( i=0; i < numVars - 1; i++ ) {
for ( j=i+1; j < numVars; j++ ) {
model.add( vars[i] != vars[j] );
} //endfor
} //endfor
// !! Alternative: a single all_different constraints
// model.add(IloAllDiff(env, vars));
// Pass the model to ILOG Solver
IloSolver solver(model);
if ( solver.solve() ) {
// Print the Solution
solver.out() << "Solution: ";
solver.out() << " S=" << (IloInt) solver.getValue(S);
solver.out() << " E=" << (IloInt) solver.getValue(E);
solver.out() << " N=" << (IloInt) solver.getValue(N);
solver.out() << " D=" << (IloInt) solver.getValue(D);
solver.out() << " M=" << (IloInt) solver.getValue(M);
solver.out() << " O=" << (IloInt) solver.getValue(O);
solver.out() << " R=" << (IloInt) solver.getValue(R);
solver.out() << " Y=" << (IloInt) solver.getValue(Y);
solver.out() << endl;
} // endif
} // endtry
catch (IloException& ex) {
cout << "Error: " << ex << endl;
} // endcatch
env.end();
return 0;
}
/*
Solution: S=9 E=5 N=6 D=7 M=1 O=0 R=8 Y=2
*/
g++ -I < ../lib/gecode-4.2.0 > /include -c sendmory.cpp
/include: Permission denied.