potassco / clasp

⚙️ A conflict-driven nogood learning answer set solver

Home Page:https://potassco.org/clasp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add New constraints

Sorcha opened this issue · comments

Hello
I apologize for bothering you.
I am working with clasp 3.3.3, directly accessing the c++ API.
I would like to ask if it is possible to add new restrictions to PbBuilder after you have performed the solve.

I have the following test:

Clasp::ClaspConfig config;
config.solve.numModels =0;
Clasp::ClaspFacade libclasp;
Clasp::PBBuilder& op =  libclasp.startPB(config);
Clasp::WeightLitVec test_query;
Clasp::WeightLitVec test2_query;
ModelPrinter printer;
op.prepareProblem(8,0,0,1);
Clasp::Literal x1(1,false);
Clasp::Literal x2(2,false);
Clasp::Literal x3(3,false);
Clasp::Literal x4(4,false);
Clasp::Literal x5(5,false);
Clasp::Literal x6(6,false);
Clasp::Literal x7(7,false);
Clasp::Literal x8(8,false);
test_query.push_back(Clasp::WeightLiteral(x1, 1));
test_query.push_back(Clasp::WeightLiteral(x2, -1));
test_query.push_back(Clasp::WeightLiteral(x3, -1));
test_query.push_back(Clasp::WeightLiteral(x4, -1));
test_query.push_back(Clasp::WeightLiteral(x5, -1));
test_query.push_back(Clasp::WeightLiteral(x6, -1));
test_query.push_back(Clasp::WeightLiteral(x7, 1));
test_query.push_back(Clasp::WeightLiteral(x8, 1));

op.addConstraint(test_query,-4,true,0);

Clasp::ClaspFacade::Result rr = libclasp.solve(&printer);

test2_query.push_back(Clasp::WeightLiteral(x1, 1));
test2_query.push_back(Clasp::WeightLiteral(x2, 1));
test2_query.push_back(Clasp::WeightLiteral(x3, -1));
test2_query.push_back(Clasp::WeightLiteral(x4, -1));
test2_query.push_back(Clasp::WeightLiteral(x5, -1));
test2_query.push_back(Clasp::WeightLiteral(x6, -1));
test2_query.push_back(Clasp::WeightLiteral(x7, 1));
test2_query.push_back(Clasp::WeightLiteral(x8, 1));

op.addConstraint(test_query,-2,false,0);

Clasp::ClaspFacade::Result r = libclasp.solve(&printer); 

I'm sorry to be putting this question here.

Thank you very much for your attention.

Please have a look at #14