void ClaspConApp::run(Clasp::ClaspFacade& clasp) { clasp.start(claspConfig_, getStream()); if (!clasp.incremental()) { claspConfig_.releaseOptions(); } if (claspAppOpts_.compute && clasp.program()->type() == Clasp::Problem_t::Asp) { bool val = claspAppOpts_.compute < 0; Clasp::Var var = static_cast<Clasp::Var>(!val ? claspAppOpts_.compute : -claspAppOpts_.compute); static_cast<Clasp::Asp::LogicProgram*>(clasp.program())->startRule().addToBody(var, val).endRule(); } auto* lp = static_cast<Clasp::Asp::LogicProgram*>(clasp.program()); auto& td = lp->theoryData(); MySharedContext s(clasp.ctx); order::Normalizer n(s,conf_); clingcon::TheoryParser tp(n,td,lp,s.trueLit()); TheoryOutput to; /// only valid for this method, but i do have pointer to it in Configurator, is this ok ? Configurator conf(conf_,n,to); claspConfig_.addConfigurator(&conf); while (clasp.read()) { if (handlePostGroundOptions(*clasp.program())) { if (lp->end() && clasp.ctx.master()->propagate()) { bool conflict = false; for (auto i = td.currBegin(); i != td.end(); ++i) { if (!tp.readConstraint(i)) throw std::runtime_error("Unknown theory atom detected, cowardly refusing to continue"); } to.names_ = std::move(tp.postProcess()); clasp.ctx.output.theory = &to; for (unsigned int level = 0; level < tp.minimize().size(); ++level) for (auto i : tp.minimize()[level]) n.addMinimize(i.second,level); if (!n.prepare()) conflict = true; else { n.checkDomains(); // may throw! if domain was not restricted s.createNewLiterals(n.estimateVariables()); if (!n.createClauses()) conflict = true; } if (conflict && !clasp.ctx.master()->hasConflict()) clasp.ctx.master()->force(Clasp::Literal(0,true)); }/// else, program is conflicting clasp.prepare(); // // // i can not update the program if it is not incremental // do i have to make my program incremental for this ? // while estimating the number of variables i have to create // a stack of new variables all the time, probably updating clasp over and over ... //clasp.update(); // //Maybe call prepare before, then update, then normalizer stuff, then prepare again // theory atoms already seem to be frozen // clasp.prepare(); if (handlePreSolveOptions(clasp)) { clasp.solve(); } } } }