Clingo
Loading...
Searching...
No Matches
Clingo::ConstModel Class Reference

Class to provide an immutable view of a model. More...

#include <solve.hh>

Inheritance diagram for Clingo::ConstModel:
Clingo::Model

Public Member Functions

 ConstModel (clingo_model_t const *mdl)
 Constructor from the underlying C representation.
 
auto symbols (ShowFlags flags=ShowFlags::shown) const -> SymbolVector
 Get the symbols of the model.
 
auto contains (Symbol const &atom) const -> bool
 Check if the model contains a specific atom.
 
auto type () const -> ModelType
 Get the type of the model.
 
auto number () const -> uint64_t
 Get the running number of the model.
 
auto is_true (ProgramLiteral lit) const -> bool
 Check whether the given literal is true in the model.
 
auto is_consequence (ProgramLiteral lit) const -> std::optional< bool >
 Check whether the given literal is consequence of the model.
 
auto cost () const -> SumSpan
 Get the cost of the model.
 
auto priorities () const -> WeightSpan
 Get the priorities of the costs of a model.
 
auto optimality_proven () const -> bool
 Check whether the model is proven to be optimal.
 
auto thread_id () const -> ProgramId
 Get the thread id of the solver that found the model.
 
auto to_string () const -> std::string
 Convert the model to a string representation.
 

Friends

auto c_cast (ConstModel const &x) -> clingo_model_t const *
 Cast the model to its C representation.
 

Detailed Description

Class to provide an immutable view of a model.

Constructor & Destructor Documentation

◆ ConstModel()

Clingo::ConstModel::ConstModel ( clingo_model_t const mdl)
inlineexplicit

Constructor from the underlying C representation.

For internal use.

Parameters
mdlthe C representation of the model

Member Function Documentation

◆ contains()

auto Clingo::ConstModel::contains ( Symbol const atom) const -> bool
inline

Check if the model contains a specific atom.

Parameters
atomthe atom to check
Returns
whether the model contains the atom

◆ cost()

auto Clingo::ConstModel::cost ( ) const -> SumSpan
inline

Get the cost of the model.

Each priority of a minimize constraint is associated with a cost.

Returns
the cost of the model

◆ is_consequence()

auto Clingo::ConstModel::is_consequence ( ProgramLiteral  lit) const -> std::optional<bool>
inline

Check whether the given literal is consequence of the model.

The function return std::nullopt if it is not known whether the literal is a consequence. Otherwise, it returns true if the literal is a consequence and false if it is not.

Parameters
litthe literal to check
Returns
whether the literal is a consequence

◆ is_true()

auto Clingo::ConstModel::is_true ( ProgramLiteral  lit) const -> bool
inline

Check whether the given literal is true in the model.

Parameters
litthe literal to check
Returns
whether the literal is true in the model

◆ number()

auto Clingo::ConstModel::number ( ) const -> uint64_t
inline

Get the running number of the model.

Returns
the running number of the model

◆ optimality_proven()

auto Clingo::ConstModel::optimality_proven ( ) const -> bool
inline

Check whether the model is proven to be optimal.

Depending on the reasoning mode and the context the model is access, this function might return false even though the model is optimal.

Returns
whether the model is proven to be optimal

◆ priorities()

auto Clingo::ConstModel::priorities ( ) const -> WeightSpan
inline

Get the priorities of the costs of a model.

Returns
the priorities of the costs

◆ symbols()

auto Clingo::ConstModel::symbols ( ShowFlags  flags = ShowFlags::shown) const -> SymbolVector
inline

Get the symbols of the model.

Parameters
flagsthe flags to select which symbols to return
Returns
the symbols of the model

◆ thread_id()

auto Clingo::ConstModel::thread_id ( ) const -> ProgramId
inline

Get the thread id of the solver that found the model.

Returns
the thread id of the solver that found the model

◆ to_string()

auto Clingo::ConstModel::to_string ( ) const -> std::string
inline

Convert the model to a string representation.

Returns
the string representation of the model

◆ type()

auto Clingo::ConstModel::type ( ) const -> ModelType
inline

Get the type of the model.

Returns
the type of the model

Friends And Related Symbol Documentation

◆ c_cast

auto c_cast ( ConstModel const x) -> clingo_model_t const *
friend

Cast the model to its C representation.

Parameters
xthe model to cast
Returns
the C representation of the model

The documentation for this class was generated from the following file: