Skip to content

Commit

Permalink
espresso stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
grencez committed Nov 19, 2023
1 parent cfc2fac commit d5541ab
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 44 deletions.
11 changes: 6 additions & 5 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ int main(int argc, char** argv)
}
if (!exec_opt.ofilepath.empty())
{
oput_protocon_file (exec_opt.ofilepath,
sys, *o_topology,
sys.actions,
exec_opt.use_espresso,
exec_opt.argline.c_str());
oput_protocon_file
(exec_opt.ofilepath,
sys, *o_topology,
sys.actions,
exec_opt.maybe_espresso,
exec_opt.argline.c_str());
}
}
std::cerr.flush();
Expand Down
5 changes: 4 additions & 1 deletion src/opt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,10 @@ protocon_options_rec
exec_opt.ofilepath = pathname2(relpath, argv[argi++]);
}
else if (eq_cstr (arg, "-espresso")) {
exec_opt.use_espresso = true;
if (!argv[argi]) {
failout_sysCx("Not enuff arguments.");
}
exec_opt.maybe_espresso = argv[argi++];
}
else if (eq_cstr (arg, "-x-test-known")) {
Xn::Sys test_sys;
Expand Down
3 changes: 1 addition & 2 deletions src/opt.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public:
std::string log_ofilename;
std::string xfilepath;
std::string ofilepath;
bool use_espresso;
std::string maybe_espresso;
std::vector<std::string> xfilepaths;
std::string model_ofilepath;
std::string graphviz_ofilepath;
Expand All @@ -75,7 +75,6 @@ public:
ProtoconOpt()
: task(SearchTask)
, nparallel( 1 )
, use_espresso( false )
, only_udp_include( false )
, conflict_order( HiLoOrder )
{}
Expand Down
5 changes: 3 additions & 2 deletions src/pla.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,12 @@ oput_protocon_pc_acts_espresso_spawn(std::ostream& out, const Xn::PcSymm& pc_sym
bool
oput_protocon_pc_acts_espresso(std::ostream& out,
const Xn::PcSymm& pc_symm,
const std::vector<Xn::ActSymm>& acts)
const std::vector<Xn::ActSymm>& acts,
const std::string& espresso_name)
{
const char* const argv[] = {
#if 1
"espresso",
espresso_name.c_str(),
// Using -Dexact can take a long time.
// "-Dexact",
#else
Expand Down
9 changes: 6 additions & 3 deletions src/pla.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#ifndef PLA_HH_
#define PLA_HH_
#include <ostream>
#include <string>
#include <vector>

#include "namespace.hh"
Expand All @@ -14,9 +15,11 @@ oput_pla_file(std::ostream& ofile, const Xn::Sys& sys);
bool
oput_pla_file(const std::string& ofilename, const Xn::Sys& sys);
bool
oput_protocon_pc_acts_espresso(std::ostream& ofile,
const Xn::PcSymm& pc_symm,
const std::vector<Xn::ActSymm>& acts);
oput_protocon_pc_acts_espresso(
std::ostream& out,
const Xn::PcSymm& pc_symm,
const std::vector<Xn::ActSymm>& acts,
const std::string& espresso_name);

END_NAMESPACE
#endif
Expand Down
27 changes: 14 additions & 13 deletions src/prot-ofile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static
bool
oput_protocon_pc_acts(std::ostream& out, const Xn::PcSymm& pc_symm,
const std::vector<Xn::ActSymm>& acts,
bool use_espresso)
const std::string& maybe_espresso)
{
const Xn::PcSymmSpec& pc_symm_spec = *pc_symm.spec;
if (pc_symm_spec.shadow_act_strings.sz() > 0) {
Expand Down Expand Up @@ -196,8 +196,8 @@ oput_protocon_pc_acts(std::ostream& out, const Xn::PcSymm& pc_symm,
out << "\n puppet:";

bool good = true;
if (use_espresso) {
good = oput_protocon_pc_acts_espresso(out, pc_symm, acts);
if (!maybe_espresso.empty()) {
good = oput_protocon_pc_acts_espresso(out, pc_symm, acts, maybe_espresso);
}
else {
for (const auto& act : acts) {
Expand Down Expand Up @@ -302,7 +302,7 @@ oput_protocon_pc_invariant(std::ostream& out, const Xn::PcSymm& pc_symm,
oput_protocon_file(std::ostream& out, const Xn::Sys& sys,
const Xn::Net& o_topology,
const vector<uint>& actions,
bool use_espresso,
const std::string& maybe_espresso,
const char* comment)
{
DeclLegit( good );
Expand Down Expand Up @@ -380,7 +380,7 @@ oput_protocon_file(std::ostream& out, const Xn::Sys& sys,
DoLegitLine("output invariant")
oput_protocon_pc_invariant(out, pc_symm, style_str);
DoLegitLine("output actions")
oput_protocon_pc_acts(out, pc_symm, acts, use_espresso);
oput_protocon_pc_acts(out, pc_symm, acts, maybe_espresso);
out << "\n}\n";
}

Expand All @@ -389,16 +389,16 @@ oput_protocon_file(std::ostream& out, const Xn::Sys& sys,

bool
oput_protocon_file(std::ostream& out, const Xn::Sys& sys, const vector<uint>& actions,
bool use_espresso, const char* comment)
const std::string& maybe_espresso, const char* comment)
{
return oput_protocon_file(out, sys, sys.topology, actions, use_espresso, comment);
return oput_protocon_file(out, sys, sys.topology, actions, maybe_espresso, comment);
}

bool
oput_protocon_file(std::ostream& out, const Xn::Sys& sys,
bool use_espresso, const char* comment)
const std::string& maybe_espresso, const char* comment)
{
return oput_protocon_file(out, sys, sys.actions, use_espresso, comment);
return oput_protocon_file(out, sys, sys.actions, maybe_espresso, comment);
}

bool
Expand All @@ -407,22 +407,23 @@ oput_protocon_file(
const Xn::Sys& sys,
const Xn::Net& o_topology,
const vector<uint>& actions,
bool use_espresso,
const std::string& maybe_espresso,
const char* comment)
{
fildesh::ofstream out(ofilename.c_str());
if (!out.good()) {return false;}
return oput_protocon_file(out, sys, o_topology, actions, use_espresso, comment);
return oput_protocon_file(out, sys, o_topology, actions, maybe_espresso, comment);
}

bool
oput_protocon_file(
const std::string& ofilename,
const Xn::Sys& sys,
bool use_espresso,
const std::string& maybe_espresso,
const char* comment)
{
return oput_protocon_file (ofilename, sys, sys.topology, sys.actions, use_espresso, comment);
return oput_protocon_file(
ofilename, sys, sys.topology, sys.actions, maybe_espresso, comment);
}

END_NAMESPACE
Expand Down
38 changes: 25 additions & 13 deletions src/prot-ofile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,35 @@
#include "namespace.hh"

bool
oput_protocon_file(std::ostream& out, const Xn::Sys& sys,
const Xn::Net& o_topology,
const vector<uint>& actions,
bool use_espresso, const char* comment);
oput_protocon_file(
std::ostream& out,
const Xn::Sys& sys, const Xn::Net& o_topology, const vector<uint>& actions,
const std::string& maybe_espresso,
const char* comment);
bool
oput_protocon_file(std::ostream& out, const Xn::Sys& sys, const vector<uint>& actions,
bool use_espresso, const char* comment);
oput_protocon_file(
std::ostream& out,
const Xn::Sys& sys, const vector<uint>& actions,
const std::string& maybe_espresso,
const char* comment);
bool
oput_protocon_file(std::ostream& out, const Xn::Sys& sys,
bool use_espresso, const char* comment);
oput_protocon_file(
std::ostream& out,
const Xn::Sys& sys,
const std::string& maybe_espresso,
const char* comment);
bool
oput_protocon_file(const std::string& ofilename,
const Xn::Sys& sys, const Xn::Net& o_topology, const vector<uint>& actions,
bool use_espresso, const char* comment);
oput_protocon_file(
const std::string& ofilename,
const Xn::Sys& sys, const Xn::Net& o_topology, const vector<uint>& actions,
const std::string& maybe_espresso,
const char* comment);
bool
oput_protocon_file(const std::string& ofilename, const Xn::Sys& sys,
bool use_espresso, const char* comment);
oput_protocon_file(
const std::string& ofilename,
const Xn::Sys& sys,
const std::string& maybe_espresso,
const char* comment);

END_NAMESPACE
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ verify_solutions(const PartialSynthesis& inst, StabilizationCkInfo* info, uint*

fildesh::ofstream livelock_out(livelock_out_filename.c_str());
oput_protocon_file(livelock_out, *inst.ctx->systems[i], inst[i].actions,
false, "livelock");
"", "livelock");
}
*inst[i].log << "Solution was NOT self-stabilizing." << std::endl;
return false;
Expand Down Expand Up @@ -686,7 +686,7 @@ void
log << "Writing system to: " << filepath << std::endl;
fildesh::ofstream prot_out(filepath.c_str());
oput_protocon_file(prot_out, sys, sys.actions,
exec_opt.use_espresso,
exec_opt.maybe_espresso,
exec_opt.argline.c_str());
}
}
Expand Down Expand Up @@ -949,7 +949,7 @@ stabilization_search(vector<uint>& ret_actions,
std::to_string(PcIdx) + "." +
std::to_string(trial_idx)).c_str());
oput_protocon_file(prot_out, sys, actions,
exec_opt.use_espresso,
exec_opt.maybe_espresso,
exec_opt.argline.c_str());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/synthesis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ PartialSynthesis::revise_actions_alone(Set<uint>& adds, Set<uint>& dels,
this->ctx->opt.n_livelock_ofiles).c_str();
this->ctx->opt.n_livelock_ofiles += 1;
fildesh::ofstream livelock_out(livelock_out_filename.c_str());
oput_protocon_file(livelock_out, sys, this->actions, false, "livelock");
oput_protocon_file(livelock_out, sys, this->actions, "", "livelock");
}
}
return false;
Expand Down
1 change: 0 additions & 1 deletion test/examplesoln/PLA_MatchRingThreeState_test.fildesh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
(: MatchRingThreeState_file Filename .self.opt.input_file)

|< protocon -nop -x $(XOF MatchRingThreeState_file) -o-pla -
|- tee /tmp/out2
|- cmp $(XOF expect_file)
|> stderr

0 comments on commit d5541ab

Please sign in to comment.