23 #ifndef _PLUGINS_ASP_ASPECT_CLINGO_ACCESS_H_ 24 #define _PLUGINS_ASP_ASPECT_CLINGO_ACCESS_H_ 26 #include <core/threading/mutex.h> 65 bool solving(
void)
const noexcept;
72 void set_num_threads(
const int threads,
const bool use_splitting =
false);
79 bool ground(
const Clingo::PartSpan &parts);
84 return assign_external(atom, value ? Clingo::TruthValue::True : Clingo::TruthValue::False);
93 bool assign_external(
const Clingo::Symbol &atom,
const Clingo::TruthValue value);
100 bool on_model(Clingo::Model &model)
override;
101 void on_finish(Clingo::SolveResult result)
override;
103 void alloc_control(
void);
107 const std::string log_comp_;
109 std::atomic<DebugLevel_t> debug_level_;
112 bool thread_mode_splitting_;
114 Mutex control_mutex_;
115 bool control_is_locked_;
116 Clingo::Control *control_;
118 mutable Mutex model_mutex_;
119 Clingo::SymbolVector model_symbols_, old_symbols_;
120 unsigned int model_counter_;
122 std::atomic_bool solving_;
123 mutable Mutex callback_mutex_;
124 std::vector<std::shared_ptr<std::function<bool(
void)>>> model_callbacks_;
125 std::vector<std::shared_ptr<std::function<void(Clingo::SolveResult)>>> finish_callbacks_;
126 Clingo::GroundCallback ground_callback_;
127 Clingo::SolveHandle async_handle_;
bool start_solving(void)
Starts the solving process, if it isn't already running.
bool free_external(const Clingo::Symbol &atom)
Release external value.
int num_threads(void) const noexcept
Returns how many threads Clingo should use.
bool load_file(const std::string &path)
Loads a file in the solver.
Fawkes library namespace.
Print which programs are grounded.
bool start_solving_blocking(void)
Starts the solving process.
Print assignments and releases of externals.
void set_debug_level(DebugLevel_t log_level)
Set debug level.
bool reset(void)
Tries to reset Clingo.
void set_ground_callback(Clingo::GroundCallback &&callback)
Sets the ground callback, to implement custom functions.
void unregister_model_callback(std::shared_ptr< std::function< bool(void)>> callback)
Unregisters a callback for the event of a new model.
bool release_external(const Clingo::Symbol &atom)
Releases an external value.
DebugLevel_t debug_level() const
Get current debug level.
Clingo::SymbolVector model_symbols(void) const
Returns a copy of the last symbols found.
void register_finish_callback(std::shared_ptr< std::function< void(Clingo::SolveResult)>> callback)
Registers a callback for the event of finishing the solving process.
DebugLevel_t
Debug levels, higher levels include the lower values.
void register_model_callback(std::shared_ptr< std::function< bool(void)>> callback)
Registers a callback for the event of a new model.
Print when starting/finishing grounding/solving for analysis.
Ignore '#show' statements and print all symbols of a model.
void unregister_finish_callback(std::shared_ptr< std::function< void(Clingo::SolveResult)>> callback)
Unregisters a callback for the event of finishing the solving process.
bool solving(void) const noexcept
Returns whether the solving process is running.
bool ground(const Clingo::PartSpan &parts)
Grounds a program part.
void set_num_threads(const int threads, const bool use_splitting=false)
Sets the number of threads Clingo should use.
A wrapper around the clingo control, to control the solving process.
ClingoAccess(Logger *logger, const std::string &log_component)
Constructor.
Mutex mutual exclusion lock.
~ClingoAccess(void)
Destructor.
bool assign_external(const Clingo::Symbol &atom, const bool value)
Assign external value.
bool cancel_solving(void)
Stops the solving process, if it is running.
Activates the –output-debug=text option for clingo.