lutzthies / hcptosat Goto Github PK
View Code? Open in Web Editor NEWEncoder and solver for Hamiltonian Cycle Problems in SAT
License: Other
Encoder and solver for Hamiltonian Cycle Problems in SAT
License: Other
Hi guys,
I actually need to check if a graph has a Hamiltonian pat. How could I do it in your solver?
I would not want to use the reduction from HP to HC since you are already using it in the other direction by solving HP.
Thanks,
Myro
Hey guys,
your code runs really fast!
What instances have you tried? Say planar graphs on 30, 50, 100 vertices?
What was the largest instance?
Thanks!
When trying to run make
in the encoders/helga_sequential
subdirectory, I get the following error:
$ make
Scanning dependencies of target helga
[ 50%] Building CXX object CMakeFiles/helga.dir/helga.cxx.o
In file included from XXX/7hal32/HCPtoSAT/encoders/helga_sequential/helga.cxx:13:0:
XXX/7hal32/HCPtoSAT/encoders/helga_sequential/../shared/SatInterface.cxx: In function ‘std::__cxx11::string execToString(const char*)’:
XXX/7hal32/HCPtoSAT/encoders/helga_sequential/../shared/SatInterface.cxx:11:9: error: ‘shared_ptr’ is not a member of ‘std’
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
^
XXX/7hal32/HCPtoSAT/encoders/helga_sequential/../shared/SatInterface.cxx:11:29: error: expected primary-expression before ‘>’ token
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
^
XXX/7hal32/HCPtoSAT/encoders/helga_sequential/../shared/SatInterface.cxx:11:59: error: ‘pipe’ was not declared in this scope
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
^
CMakeFiles/helga.dir/build.make:62: recipe for target 'CMakeFiles/helga.dir/helga.cxx.o' failed
make[2]: *** [CMakeFiles/helga.dir/helga.cxx.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helga.dir/all' failed
make[1]: *** [CMakeFiles/helga.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
From looking around, I see shared_ptr
is presumably defined in the memory
header file. Adding an include to encoders/shared/SatInterface.cxx
allows the compilation to go through.
Here is a diff:
$ git diff
diff --git a/encoders/shared/SatInterface.cxx b/encoders/shared/SatInterface.cxx
index 031f2fa..a8a2223 100644
--- a/encoders/shared/SatInterface.cxx
+++ b/encoders/shared/SatInterface.cxx
@@ -1,6 +1,8 @@
#include <string>
#include <stdlib.h>
+#include <memory>
+
// run cmd and write it to std::to_string
// idea by http://stackoverflow.com/questions/478898/how-to-execute-a-command-and-get-output-of-command-within-c-using-posix
std::string execToString(const char* cmd) {
Happy to submit a PR if that's helpful.
Hello!
I'm currently working in a similar scholar project and I'd like to know what clauses are you using to reduce the hamiltonian path problem to a SAT instance?
Are you using any additional heuristic for optimization?
Thank you
Hey, guys
how can I predefine the path to in.txt file? I mean, how do I set the folder where the encoder writes in.txt and where the solver can find it. So far it seems to be automatically chosen, which is inconvenient since I want to run many parallel experiments.
Thanks!
Tried this input graph, which is just K_4
p edge 4 6
e 1 2
e 1 3
e 1 4
e 2 3
e 2 4
e 3 4
And the solver says UNSATISFIABLE :(
I am running the command:
./helga.out ../../graphs/hc-4.col "../../solvers/lingeling/plingeling in.txt"
And then I get some output:
parsing graph from file into adjacency matrix
constraint (3) FINISHED (from 1 to -2)
constraint (1) finished
constraint (2) finished
constraint (4) finished
constraint (5) finished
constraint (6) finished
INFO - writing results to file
INFO - starting solver with provided command
SUCCESS - solver finished and returned result
s SATISFIABLE
but no path itself.
Am I doing something wrong?
Non PB versions are not compiling for me.
PB version brings wrong results. #3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.