Skip to content

Commit

Permalink
debugged unigen and cmsgen to correctly give multisample [working]
Browse files Browse the repository at this point in the history
  • Loading branch information
arijitsh committed Apr 3, 2024
1 parent da775a3 commit 7892cc6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/stp/Sat/UniSamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class UniSamp : public SATSolver

public:
UniSamp(uint64_t unisamp_seed, uint64_t samples_needed,
uint64_t samples_generated);
uint64_t _samples_generated);

~UniSamp();

Expand Down
4 changes: 2 additions & 2 deletions lib/STPManager/STP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ SATSolver* STP::get_new_sat_solver()
case UserDefinedFlags::UNIGEN_SOLVER:
#ifdef USE_UNIGEN
newS = new UniSamp(bm->UserFlags.unisamp_seed, bm->UserFlags.num_samples,
bm->UserFlags.samples_generated);
bm->UserFlags.samples_generated);
#else
std::cerr << "UniSamp support was not enabled at configure time."
<< std::endl;
Expand All @@ -125,7 +125,7 @@ SATSolver* STP::get_new_sat_solver()
case UserDefinedFlags::APPROXMC_SOLVER:
#ifdef USE_UNIGEN
newS = new UniSamp(bm->UserFlags.unisamp_seed, bm->UserFlags.num_samples,
bm->UserFlags.samples_generated);
bm->UserFlags.samples_generated);
#else
std::cerr << "UniSamp support was not enabled at configure time."
<< std::endl;
Expand Down
8 changes: 5 additions & 3 deletions lib/Sat/UniSamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ bool UniSamp::solve(bool& timeout_expired) // Search without assumptions.
*/

// CMSat::lbool ret = s->solve(); // TODO AS
samples_generated += 1;
if (unisamp_ran)
samples_generated++;
std::cout << "c [stp->unigen] Generating Sample number " << samples_generated
<< std::endl;
if (samples_generated > 1)
return true;

std::cout << "c [stp->unigen] UniSamp solving instance with " << a->nVars()
Expand Down Expand Up @@ -189,7 +191,7 @@ uint8_t UniSamp::modelValue(uint32_t x) const
{
// if (unigen_models[0].size() < sampling_vars.size())
// std::cout << "c [stp->unigen] ERROR! found model size is not large enough\n";
return (unigen_models[samples_generated - 1].at(x) > 0);
return (unigen_models[samples_generated].at(x) > 0);
}

uint32_t UniSamp::newVar()
Expand Down
27 changes: 13 additions & 14 deletions tools/stp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,19 @@ void ExtraMain::create_options()
"(default)"
#endif
#endif
)("unisamp,u", "use unisamp as solver -- behave as a almost "
"uniform sampler")(
"cmsgen,s",
"use cmsgen as solver -- behave as a uniform like sampler")(
"approxmc,c",
"use approxmc as solver -- behave as a approximate counter")(
"seed",
po::value<uint64_t>(&bm->UserFlags.unisamp_seed)
->default_value(bm->UserFlags.unisamp_seed),
"Seed for counting and sampling")(
"num-samples,ns",
po::value<uint64_t>(&bm->UserFlags.num_samples)
->default_value(bm->UserFlags.num_samples),
"Number of samples to generate in case of sampling");
)("unisamp,u", "use unisamp as solver -- behave as a almost-uniform sampler")(
"cmsgen,s",
"use cmsgen as solver -- behave as a uniform like sampler")(
"approxmc,c",
"use approxmc as solver -- behave as a approximate counter")(
"seed",
po::value<uint64_t>(&bm->UserFlags.unisamp_seed)
->default_value(bm->UserFlags.unisamp_seed),
"Seed for counting and sampling")(
"num-samples,ns",
po::value<uint64_t>(&bm->UserFlags.num_samples)
->default_value(bm->UserFlags.num_samples),
"Number of samples to generate in sampling mode");
;

po::options_description refinement_options("Refinement options");
Expand Down

0 comments on commit 7892cc6

Please sign in to comment.