Skip to content

Commit

Permalink
seed to get different samples
Browse files Browse the repository at this point in the history
  • Loading branch information
arijitsh committed Nov 30, 2023
1 parent 4413e46 commit b9e3a2f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ The [SMT-LIB2](https://smtlib.cs.uiowa.edu/language.shtml) format is the recomme
Run with an SMT-LIB2 file:

```
./stp --unisamp myproblem.smt2
./stp --unisamp --seed 6 myproblem.smt2
```

Change seed value to get different samples.

### Usage

Expand Down
1 change: 1 addition & 0 deletions include/stp/STPManager/UserDefinedFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct UserDefinedFlags

int64_t timeout_max_conflicts = -1;
int num_solver_threads = 1;
uint64_t unisamp_seed = 12345;
int64_t timeout_max_time = -1; // seconds

// check the counterexample against the original input to STP
Expand Down
3 changes: 2 additions & 1 deletion include/stp/Sat/UniSamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ namespace stp
ApproxMC::AppMC* a;
UniGen::UniG* s;
ArjunNS::Arjun* arjun;
uint64_t seed;

public:
UniSamp();
UniSamp(uint64_t unisamp_seed);

~UniSamp();

Expand Down
2 changes: 1 addition & 1 deletion lib/STPManager/STP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ SATSolver* STP::get_new_sat_solver()
break;
case UserDefinedFlags::UNIGEN_SOLVER:
#ifdef USE_UNIGEN
newS = new UniSamp();
newS = new UniSamp(bm->UserFlags.unisamp_seed);
#else
std::cerr << "UniSamp support was not enabled at configure time."
<< std::endl;
Expand Down
4 changes: 3 additions & 1 deletion lib/Sat/UniSamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ void UniSamp::enableRefinement(const bool enable)
// }
}

UniSamp::UniSamp()
UniSamp::UniSamp(uint64_t unisamp_seed)
{

a = new ApproxMC::AppMC;
s = new UniG(a);
arjun = new ArjunNS::Arjun;
seed = unisamp_seed;

s->set_callback(mycallback, NULL);
a->set_verbosity(1);
a->set_seed(seed);
// s->log_to_file("stp.cnf");
//s->set_num_threads(num_threads);
//s->set_default_polarity(false);
Expand Down
6 changes: 5 additions & 1 deletion tools/stp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ void ExtraMain::create_options()
#endif
#endif
)
("unisamp", "use unisamp as solver -- behave as a uniform sampler");
("unisamp", "use unisamp as solver -- behave as a uniform sampler")
("seed",
po::value<uint64_t>(&bm->UserFlags.unisamp_seed)
->default_value(bm->UserFlags.unisamp_seed),
"Seed for UniSamp");

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

0 comments on commit b9e3a2f

Please sign in to comment.