Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kučera Petr RNDr. Ph.D.
PCCompile
Commits
79b98ea8
Commit
79b98ea8
authored
Sep 01, 2021
by
Kučera Petr RNDr. Ph.D.
Browse files
pccompile solvers options
parent
ad7518b4
Changes
6
Hide whitespace changes
Inline
Side-by-side
bin/pccheck.cpp
View file @
79b98ea8
...
...
@@ -112,8 +112,8 @@ dump_config(const config_t &conf, unsigned level)
"
\t
"
,
level
,
"amo_encoding"
,
conf
.
amo_encoding
);
SUBool
::
ExOneEncoder
::
kKindAnnotation
.
DumpValue
(
"
\t
"
,
level
,
"exone_encoding"
,
conf
.
exone_encoding
);
SUBool
::
dump_enum_v
alue
(
"
\t
"
,
level
,
"solver_type"
,
conf
.
solver_type
,
SUBool
::
kSolverTypeNames
);
SUBool
::
kSolverTypeAnnotation
.
DumpV
alue
(
"
\t
"
,
level
,
"solver_type"
,
conf
.
solver_type
);
SUBool
::
logs
.
TLog
(
level
)
<<
"END"
<<
std
::
endl
;
}
...
...
bin/pccompile.cpp
View file @
79b98ea8
...
...
@@ -152,8 +152,8 @@ dump_config(const config_t &conf, unsigned level)
SUBool
::
logs
.
TLog
(
level
)
<<
"
\t
comp_base_config.timeouts.level_factor: "
<<
conf
.
comp_base_config
.
timeouts
.
level_factor
<<
std
::
endl
;
SUBool
::
dump_enum_value
(
"
\t
"
,
level
,
"cop_base_config.solver_type"
,
conf
.
comp_base_config
.
solver_type
,
SUBool
::
kSolverTypeNames
);
SUBool
::
kSolverTypeAnnotation
.
DumpValue
(
"
\t
"
,
level
,
"comp_base_config.solver_type"
,
conf
.
comp_base_config
.
solver_type
);
SUBool
::
logs
.
TLog
(
level
)
<<
"
\t
enc_conf:"
<<
std
::
endl
;
conf
.
comp_base_config
.
enc_conf
.
Dump
(
"
\t\t
"
,
level
);
SUBool
::
AmoEncoder
::
kKindAnnotation
.
DumpValue
(
...
...
@@ -205,6 +205,7 @@ parse_arguments(int argc, char *argv[], config_t &conf)
auto
pclearncomp_opts
=
opts
.
MakeOptionsGroup
<
SUBool
::
PCLearnCompOptions
>
();
auto
preprocess_opts
=
opts
.
MakeOptionsGroup
<
SUBool
::
PCCompPreprocessOptions
>
();
auto
solver_opts
=
opts
.
MakeOptionsGroup
<
SUBool
::
PCSolverOptions
>
();
if
(
!
opts
.
Parse
(
argc
,
argv
))
{
return
1
;
...
...
@@ -217,6 +218,7 @@ parse_arguments(int argc, char *argv[], config_t &conf)
conf
.
comp_base_config
.
preprocess
=
preprocess_opts
->
PreprocessMethod
();
conf
.
comp_base_config
.
propagate_backbones
=
!
preprocess_opts
->
NoBackbonePropagation
();
conf
.
comp_base_config
.
solver_type
=
solver_opts
->
SolverType
();
return
0
;
#if 0
try
...
...
lib/pc_opt.cpp
View file @
79b98ea8
...
...
@@ -89,3 +89,19 @@ SUBool::PCCompPreprocessOptions::GetValues()
{
return
mPreprocessMethodOption
.
GetValue
(
mPreprocessMethod
);
}
SUBool
::
PCSolverOptions
::
PCSolverOptions
()
:
OptionsGroup
(
"Solvers"
),
mSolverTypeOption
(
kSolverTypeAnnotation
,
"pccheck-solver"
,
"Solver to be used for the PC check. Only the available solvers are "
"listed."
,
kDefaultSolverType
)
{
Add
(
mSolverTypeOption
);
}
bool
SUBool
::
PCSolverOptions
::
GetValues
()
{
return
mSolverTypeOption
.
GetValue
(
mSolverType
);
}
lib/pc_opt.h
View file @
79b98ea8
...
...
@@ -89,6 +89,23 @@ namespace SUBool
AbsComp
::
PREPROCESS_METHOD
PreprocessMethod
()
const
;
};
// Solver selection
class
PCSolverOptions
:
public
OptionsGroup
{
public:
static
const
SOLVER_TYPE
kDefaultSolverType
=
SOLVER_TYPE
::
GLUCOSE
;
private:
EnumOption
<
SOLVER_TYPE
>
mSolverTypeOption
;
SOLVER_TYPE
mSolverType
{
kDefaultSolverType
};
public:
PCSolverOptions
();
virtual
bool
GetValues
()
override
;
SOLVER_TYPE
SolverType
()
const
;
};
}
// namespace SUBool
inline
auto
...
...
@@ -122,4 +139,10 @@ SUBool::PCCompPreprocessOptions::PreprocessMethod() const
return
mPreprocessMethod
;
}
inline
SUBool
::
SOLVER_TYPE
SUBool
::
PCSolverOptions
::
SolverType
()
const
{
return
mSolverType
;
}
#endif
lib/solver_bind.cpp
View file @
79b98ea8
...
...
@@ -15,9 +15,15 @@ std::atomic<long unsigned> SUBool::SolverInterface::sSolveCountUNSAT;
std
::
atomic
<
long
unsigned
>
SUBool
::
SolverInterface
::
sSolveCountUNDEF
;
SUBool
::
SolverPool
SUBool
::
SolverPool
::
sDefaultPool
;
const
std
::
array
<
std
::
string
,
static_cast
<
size_t
>
(
SUBool
::
SOLVER_TYPE
::
Last
)
+
1
>
SUBool
::
kSolverTypeNames
{
"glucose"
,
"kissat"
};
const
SUBool
::
EnumAnnotation
<
SUBool
::
SOLVER_TYPE
>
SUBool
::
kSolverTypeAnnotation
(
"SOLVER_TYPE"
,
{
//
{
SOLVER_TYPE
::
GLUCOSE
,
"glucose"
,
"use glucose."
}
#if HAS_KISSAT
,
{
SOLVER_TYPE
::
KISSAT
,
"kissat"
,
"use kissat."
}
#endif
});
bool
SUBool
::
SolverInterface
::
AddClauses
(
const
std
::
vector
<
Clause
>
&
clauses
)
...
...
@@ -37,24 +43,26 @@ SUBool::SolverPool::InterruptAll()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mMutex
);
std
::
for_each
(
mSolverList
.
begin
(),
mSolverList
.
end
(),
[](
auto
&
h
)
{
h
.
solver
->
Interrupt
();
});
[](
auto
&
h
)
{
h
.
solver
->
Interrupt
();
});
}
void
SUBool
::
SolverPool
::
InterruptInThread
(
std
::
thread
::
id
thread_id
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mMutex
);
std
::
for_each
(
mSolverList
.
begin
(),
mSolverList
.
end
(),
[
thread_id
](
auto
&
h
)
{
if
(
h
.
thread_id
==
thread_id
)
{
h
.
solver
->
Interrupt
();
}
});
std
::
for_each
(
mSolverList
.
begin
(),
mSolverList
.
end
(),
[
thread_id
](
auto
&
h
)
{
if
(
h
.
thread_id
==
thread_id
)
{
h
.
solver
->
Interrupt
();
}
});
}
SUBool
::
AbsSolverWrapper
SUBool
::
solver_wrapper
(
SOLVER_TYPE
solver_type
,
SolverInterface
::
ADAPTATION
adapt
)
SUBool
::
solver_wrapper
(
SOLVER_TYPE
solver_type
,
SolverInterface
::
ADAPTATION
adapt
)
{
switch
(
solver_type
)
{
...
...
@@ -64,12 +72,12 @@ SUBool::solver_wrapper(SOLVER_TYPE solver_type,
#if HAS_KISSAT
return
KissatSolverWrapper
(
adapt
);
#else
throw
BadParameterException
(
"AbsCheckerSAT::NewSolverWrapper"
,
"Kissat support not available"
);
throw
BadParameterException
(
"AbsCheckerSAT::NewSolverWrapper"
,
"Kissat support not available"
);
#endif
default:
throw
BadParameterException
(
"AbsCheckerSAT::NewSolverWrapper"
,
"Unknown solver type"
);
throw
BadParameterException
(
"AbsCheckerSAT::NewSolverWrapper"
,
"Unknown solver type"
);
}
};
lib/solver_bind.h
View file @
79b98ea8
...
...
@@ -15,6 +15,7 @@
#include <optional>
#include <thread>
#include "enum.h"
#include "normalform.h"
namespace
SUBool
...
...
@@ -86,8 +87,7 @@ namespace SUBool
PartialValue
SolveWithTimeout
(
const
std
::
chrono
::
duration
<
Rep
,
Period
>
&
timeout_duration
)
const
;
template
<
class
Rep
,
class
Period
>
PartialValue
SolveWithTimeout
(
const
std
::
vector
<
Literal
>
&
assump
,
PartialValue
SolveWithTimeout
(
const
std
::
vector
<
Literal
>
&
assump
,
const
std
::
chrono
::
duration
<
Rep
,
Period
>
&
timeout_duration
)
const
;
virtual
PartialValue
ValueOfVariable
(
unsigned
var
)
const
=
0
;
...
...
@@ -225,16 +225,13 @@ namespace SUBool
enum
class
SOLVER_TYPE
{
GLUCOSE
,
KISSAT
,
Last
=
KISSAT
KISSAT
};
extern
const
std
::
array
<
std
::
string
,
static_cast
<
size_t
>
(
SOLVER_TYPE
::
Last
)
+
1
>
kSolverTypeNames
;
extern
const
EnumAnnotation
<
SOLVER_TYPE
>
kSolverTypeAnnotation
;
AbsSolverWrapper
solver_wrapper
(
SOLVER_TYPE
solver_type
,
SolverInterface
::
ADAPTATION
adapt
);
AbsSolverWrapper
solver_wrapper
(
SOLVER_TYPE
solver_type
,
SolverInterface
::
ADAPTATION
adapt
);
template
<
class
S
>
class
SolverWrapperTemplate
:
public
AbsSolverWrapper
{
...
...
@@ -265,12 +262,11 @@ SUBool::SolverInterface::SolveWithTimeout(
template
<
class
Rep
,
class
Period
>
SUBool
::
PartialValue
SUBool
::
SolverInterface
::
SolveWithTimeout
(
const
std
::
vector
<
Literal
>
&
assump
,
SUBool
::
SolverInterface
::
SolveWithTimeout
(
const
std
::
vector
<
Literal
>
&
assump
,
const
std
::
chrono
::
duration
<
Rep
,
Period
>
&
timeout_duration
)
const
{
auto
fut
=
std
::
async
(
std
::
launch
::
async
,
[
this
,
&
assump
]()
{
return
Solve
(
assump
);
});
auto
fut
=
std
::
async
(
std
::
launch
::
async
,
[
this
,
&
assump
]()
{
return
Solve
(
assump
);
});
if
(
fut
.
wait_for
(
timeout_duration
)
==
std
::
future_status
::
timeout
)
{
Interrupt
();
...
...
@@ -286,7 +282,7 @@ SUBool::SolverPool::NewSolver(Args &&...arg)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mMutex
);
mSolverList
.
emplace_back
(
std
::
this_thread
::
get_id
(),
std
::
make_unique
<
S
>
(
std
::
forward
<
Args
>
(
arg
)...));
std
::
make_unique
<
S
>
(
std
::
forward
<
Args
>
(
arg
)...));
return
std
::
prev
(
mSolverList
.
end
());
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment