clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Clasp::SharedMinimizeData Class Reference

A type holding data (possibly) shared between a set of minimize constraints. More...

#include <minimize_constraint.h>

Collaboration diagram for Clasp::SharedMinimizeData:
Collaboration graph

Classes

struct  LevelWeight
 A type to represent a weight at a certain level. More...
 

Public Types

typedef SharedMinimizeData ThisType
 
typedef PodVector< LevelWeight >
::type 
WeightVec
 A type for holding sparse vectors of level weights of a multi-level constraint. More...
 

Public Member Functions

 SharedMinimizeData (const SumVec &lhsAdjust, MinimizeMode m=MinimizeMode_t::optimize)
 
ThisTypeshare ()
 Increases the reference count of this object. More...
 
void release ()
 Decreases the object's reference count and destroys it if reference count drops to 0. More...
 
uint32 numRules () const
 Number of minimize statements contained in this constraint. More...
 
uint32 maxLevel () const
 
MinimizeMode mode () const
 Returns the active minimization mode. More...
 
bool optimize () const
 Returns true if optimization is active. More...
 
wsum_t lower (uint32 x) const
 Returns the lower bound of level x. More...
 
const wsum_tlower () const
 
wsum_t upper (uint32 x) const
 Returns the upper bound of level x. More...
 
const wsum_tupper () const
 
wsum_t adjust (uint32 x) const
 Returns the adjustment for level x. More...
 
wsum_t optimum (uint32 x) const
 Returns the current (ajusted and possibly tentative) optimum for level x. More...
 
uint32 level (uint32 i) const
 Returns the highest level of the literal with the given index i. More...
 
weight_t weight (uint32 i) const
 Returns the most important weight of the literal with the given index i. More...
 
uint32 generation () const
 
bool checkNext () const
 Returns whether minimization should search for solutions with current or next smaller upper bound. More...
 
bool heuristic (Solver &s, bool full) const
 Assumes literals from last model to false until either a conflict is reached or all literals are assigned. More...
 
interface for optimization

The following functions shall not be called concurrently.

bool setMode (MinimizeMode m, const wsum_t *bound=0, uint32 boundSize=0)
 Sets the enumeration mode and (optionally) an initial bound. More...
 
bool setMode (MinimizeMode m, const SumVec &bound)
 
void resetBounds ()
 
MinimizeConstraintattach (Solver &s, uint32 strat=UINT32_MAX, bool addRef=true)
 Attaches a new minimize constraint to this data object. More...
 
const SumVecsetOptimum (const wsum_t *opt)
 Makes opt the new (tentative) optimum. More...
 
void setLower (uint32 lev, wsum_t low)
 Sets the lower bound of level lev to low. More...
 
void markOptimal ()
 Marks the current tentative optimum as the final optimum. More...
 
Arithmetic functions on weights.
void add (wsum_t *lhs, const WeightLiteral &lit) const
 Computes lhs += weight(lit). More...
 
void add (wsum_t *lhs, const LevelWeight *w) const
 
void sub (wsum_t *lhs, const WeightLiteral &lit, uint32 &aLev) const
 Computes lhs -= weight(lit). More...
 
void sub (wsum_t *lhs, const LevelWeight *w, uint32 &aLev) const
 
bool imp (wsum_t *lhs, const WeightLiteral &lit, const wsum_t *rhs, uint32 &lev) const
 Returns (lhs + weight(lit)) > rhs. More...
 
bool imp (wsum_t *lhs, const LevelWeight *w, const wsum_t *rhs, uint32 &lev) const
 
weight_t weight (const WeightLiteral &lit, uint32 lev) const
 Returns the weight of lit at level lev. More...
 

Static Public Member Functions

static wsum_t maxBound ()
 

Public Attributes

WeightVec weights
 
WeightLiteral lits [0]
 

Detailed Description

A type holding data (possibly) shared between a set of minimize constraints.

Member Typedef Documentation

A type for holding sparse vectors of level weights of a multi-level constraint.

Constructor & Destructor Documentation

Clasp::SharedMinimizeData::SharedMinimizeData ( const SumVec lhsAdjust,
MinimizeMode  m = MinimizeMode_t::optimize 
)
explicit

Here is the call graph for this function:

Member Function Documentation

void Clasp::SharedMinimizeData::add ( wsum_t lhs,
const WeightLiteral lit 
) const
inline

Computes lhs += weight(lit).

void Clasp::SharedMinimizeData::add ( wsum_t lhs,
const LevelWeight w 
) const
inline
wsum_t Clasp::SharedMinimizeData::adjust ( uint32  x) const
inline

Returns the adjustment for level x.

MinimizeConstraint * Clasp::SharedMinimizeData::attach ( Solver s,
uint32  strat = UINT32_MAX,
bool  addRef = true 
)

Attaches a new minimize constraint to this data object.

Parameters
stratThe optimization strategy to use (see SolverStrategies::OptStrategy). If UINT32_MAX, the strategy is read from the solver's configuration.
addRefIf true, the ref count of the shared object is increased. Otherwise, the new minimize constraint inherits the reference to the shared object.

Here is the call graph for this function:

bool Clasp::SharedMinimizeData::checkNext ( ) const
inline

Returns whether minimization should search for solutions with current or next smaller upper bound.

Here is the call graph for this function:

uint32 Clasp::SharedMinimizeData::generation ( ) const
inline
bool Clasp::SharedMinimizeData::heuristic ( Solver s,
bool  full 
) const

Assumes literals from last model to false until either a conflict is reached or all literals are assigned.

Here is the call graph for this function:

bool Clasp::SharedMinimizeData::imp ( wsum_t lhs,
const WeightLiteral lit,
const wsum_t rhs,
uint32 &  lev 
) const
inline

Returns (lhs + weight(lit)) > rhs.

bool Clasp::SharedMinimizeData::imp ( wsum_t lhs,
const LevelWeight w,
const wsum_t rhs,
uint32 &  lev 
) const

Here is the call graph for this function:

uint32 Clasp::SharedMinimizeData::level ( uint32  i) const
inline

Returns the highest level of the literal with the given index i.

Here is the call graph for this function:

wsum_t Clasp::SharedMinimizeData::lower ( uint32  x) const
inline

Returns the lower bound of level x.

const wsum_t* Clasp::SharedMinimizeData::lower ( ) const
inline
void Clasp::SharedMinimizeData::markOptimal ( )

Marks the current tentative optimum as the final optimum.

Note
Once a final optimum is set, further calls to setOptimum() are ignored until resetBounds() is called.

Here is the call graph for this function:

static wsum_t Clasp::SharedMinimizeData::maxBound ( )
inlinestatic
uint32 Clasp::SharedMinimizeData::maxLevel ( ) const
inline

Here is the call graph for this function:

MinimizeMode Clasp::SharedMinimizeData::mode ( ) const
inline

Returns the active minimization mode.

uint32 Clasp::SharedMinimizeData::numRules ( ) const
inline

Number of minimize statements contained in this constraint.

bool Clasp::SharedMinimizeData::optimize ( ) const
inline

Returns true if optimization is active.

Here is the call graph for this function:

wsum_t Clasp::SharedMinimizeData::optimum ( uint32  x) const
inline

Returns the current (ajusted and possibly tentative) optimum for level x.

Here is the call graph for this function:

void Clasp::SharedMinimizeData::release ( )
inline

Decreases the object's reference count and destroys it if reference count drops to 0.

void Clasp::SharedMinimizeData::resetBounds ( )

Here is the call graph for this function:

void Clasp::SharedMinimizeData::setLower ( uint32  lev,
wsum_t  low 
)

Sets the lower bound of level lev to low.

bool Clasp::SharedMinimizeData::setMode ( MinimizeMode  m,
const wsum_t bound = 0,
uint32  boundSize = 0 
)

Sets the enumeration mode and (optionally) an initial bound.

Note
If m is MinimizeMode::enumerate, the caller should always set a bound. Otherwise, all solutions are considered valid.

Here is the call graph for this function:

bool Clasp::SharedMinimizeData::setMode ( MinimizeMode  m,
const SumVec bound 
)
inline

Here is the call graph for this function:

const SumVec * Clasp::SharedMinimizeData::setOptimum ( const wsum_t opt)

Makes opt the new (tentative) optimum.

Precondition
opt is a pointer to an array of size numRules()

Here is the call graph for this function:

ThisType* Clasp::SharedMinimizeData::share ( )
inline

Increases the reference count of this object.

void Clasp::SharedMinimizeData::sub ( wsum_t lhs,
const WeightLiteral lit,
uint32 &  aLev 
) const
inline

Computes lhs -= weight(lit).

void Clasp::SharedMinimizeData::sub ( wsum_t lhs,
const LevelWeight w,
uint32 &  aLev 
) const
wsum_t Clasp::SharedMinimizeData::upper ( uint32  x) const
inline

Returns the upper bound of level x.

Here is the call graph for this function:

const wsum_t* Clasp::SharedMinimizeData::upper ( ) const
inline
weight_t Clasp::SharedMinimizeData::weight ( uint32  i) const
inline

Returns the most important weight of the literal with the given index i.

Here is the call graph for this function:

weight_t Clasp::SharedMinimizeData::weight ( const WeightLiteral lit,
uint32  lev 
) const
inline

Returns the weight of lit at level lev.

Here is the call graph for this function:

Member Data Documentation

WeightLiteral Clasp::SharedMinimizeData::lits[0]
WeightVec Clasp::SharedMinimizeData::weights

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