potassco / clasp

⚙️ A conflict-driven nogood learning answer set solver
https://potassco.org/clasp/
MIT License
117 stars 16 forks source link

Add New constraints #35

Closed Sorcha closed 5 years ago

Sorcha commented 6 years ago

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.

rkaminsk commented 6 years ago

I think that the PbBuilder has not been build with incremental programs in mind. So far incremental solving is only available for logic programs.

On Thursday, June 28, 2018 7:35:38 PM CEST Ana Correia wrote:

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.

BenKaufmann commented 6 years ago

Please have a look at https://github.com/potassco/clasp/issues/14