Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
59 kB · 1810 lines
C++
at develop
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- *//* * Main authors: * Christian Schulte <schulte@gecode.org> * * Contributing authors: * Samuel Gagnon <samuel.gagnon92@gmail.com> * * Copyright: * Christian Schulte, 2005 * Samuel Gagnon, 2018 * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */
#include <iostream>
namespace Gecode { namespace Int {
/** * \brief Range iterator for integer views * * This class provides (by specialization) a range iterator * for all integer views. * * Note that this template class serves only as a specification * of the interface of the various specializations. * * \ingroup TaskActorInt */ template<class View> class ViewRanges { public: /// \name Constructors and initialization //@{ /// Default constructor ViewRanges(void); /// Initialize with ranges for view \a x ViewRanges(const View& x); /// Initialize with ranges for view \a x void init(const View& x); //@}
/// \name Iteration control //@{ /// Test whether iterator is still at a range or done bool operator ()(void) const; /// Move iterator to next range (if possible) void operator ++(void); //@}
/// \name Range access //@{ /// Return smallest value of range int min(void) const; /// Return largest value of range int max(void) const; /// Return width of range (distance between minimum and maximum) unsigned int width(void) const; //@} };
/** * \brief Value iterator for integer views * * This class provides a value iterator for all * integer views. * * \ingroup TaskActorInt */ template<class View> class ViewValues : public Iter::Ranges::ToValues<ViewRanges<View> > { public: /// \name Constructors and initialization //@{ /// Default constructor ViewValues(void); /// Initialize with values for \a x ViewValues(const View& x); /// Initialize with values \a x void init(const View& x); //@} };
}}
#include <gecode/int/view/iter.hpp>
namespace Gecode { namespace Int {
/** * \defgroup TaskActorIntView Integer views * * Integer propagators and branchers compute with integer views. * Integer views provide views on integer variable implementations, * integer constants, and also allow to scale, translate, and negate * variables. Additionally, a special Boolean view is provided that * offers convenient and efficient operations for Boolean (0/1) * views. * \ingroup TaskActorInt */
/** * \brief Integer view for integer variables * \ingroup TaskActorIntView */ class IntView : public VarImpView<IntVar> { protected: using VarImpView<IntVar>::x; public: /// \name Constructors and initialization //@{ /// Default constructor IntView(void); /// Initialize from integer variable \a y IntView(const IntVar& y); /// Initialize from integer variable \a y IntView(IntVarImp* y); //@}
/// \name Value access //@{ /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return median of domain (greatest element not greater than the median) int med(void) const; /// Return assigned value (only if assigned) int val(void) const;#ifdef GECODE_HAS_CBS /// Return reverse transformation of value according to view int baseval(int val) const;#endif
/// Return size (cardinality) of domain unsigned int size(void) const; /// Return width of domain (distance between maximum and minimum) unsigned int width(void) const; /// Return regret of domain minimum (distance to next larger value) unsigned int regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) unsigned int regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const;
/// Test whether \a n is contained in domain bool in(int n) const; /// Test whether \a n is contained in domain bool in(long long int n) const; //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@}
/** * \name Domain update by iterator * * Views can be both updated by range and value iterators. * Value iterators do not need to be strict in that the same value * is allowed to occur more than once in the iterated sequence. * * The argument \a depends must be true, if the iterator * passed as argument depends on the view on which the operation * is invoked. In this case, the view is only updated after the * iterator has been consumed. Otherwise, the domain might be updated * concurrently while following the iterator. * */ //@{ /// Replace domain by ranges described by \a i template<class I> ModEvent narrow_r(Space& home, I& i, bool depends=true); /// Intersect domain with ranges described by \a i template<class I> ModEvent inter_r(Space& home, I& i, bool depends=true); /// Remove from domain the ranges described by \a i template<class I> ModEvent minus_r(Space& home, I& i, bool depends=true); /// Replace domain by values described by \a i template<class I> ModEvent narrow_v(Space& home, I& i, bool depends=true); /// Intersect domain with values described by \a i template<class I> ModEvent inter_v(Space& home, I& i, bool depends=true); /// Remove from domain the values described by \a i template<class I> ModEvent minus_v(Space& home, I& i, bool depends=true); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; //@}
/// \name View-dependent propagator support //@{ /// Translate modification event \a me to modification event delta for view static ModEventDelta med(ModEvent me); //@} };
/** * \brief Print integer variable view * \relates Gecode::Int::IntView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const IntView& x);
/** * \brief Minus integer view * * A minus integer view \f$m\f$ for an integer view \f$x\f$ provides * operations such that \f$m\f$ behaves as \f$-x\f$. * \ingroup TaskActorIntView */ class MinusView : public DerivedView<IntView> { protected: using DerivedView<IntView>::x; public: /// \name Constructors and initialization //@{ /// Default constructor MinusView(void); /// Initialize with integer view \a y explicit MinusView(const IntView& y); //@}
/// \name Value access //@{ /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return median of domain int med(void) const; /// Return assigned value (only if assigned) int val(void) const;#ifdef GECODE_HAS_CBS /// Return reverse transformation of value according to view int baseval(int val) const;#endif
/// Return size (cardinality) of domain unsigned int size(void) const; /// Return width of domain (distance between maximum and minimum) unsigned int width(void) const; /// Return regret of domain minimum (distance to next larger value) unsigned int regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) unsigned int regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const;
/// Test whether \a n is contained in domain bool in(int n) const; /// Test whether \a n is contained in domain bool in(long long int n) const; //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@}
/** * \name Domain update by iterator * * Views can be both updated by range and value iterators. * Value iterators do not need to be strict in that the same value * is allowed to occur more than once in the iterated sequence. * * The argument \a depends must be true, if the iterator * passed as argument depends on the view on which the operation * is invoked. In this case, the view is only updated after the * iterator has been consumed. Otherwise, the domain might be updated * concurrently while following the iterator. * */ //@{ /// Replace domain by ranges described by \a i template<class I> ModEvent narrow_r(Space& home, I& i, bool depends=true); /// Intersect domain with ranges described by \a i template<class I> ModEvent inter_r(Space& home, I& i, bool depends=true); /// Remove from domain the ranges described by \a i template<class I> ModEvent minus_r(Space& home, I& i, bool depends=true); /// Replace domain by values described by \a i template<class I> ModEvent narrow_v(Space& home, I& i, bool depends=true); /// Intersect domain with values described by \a i template<class I> ModEvent inter_v(Space& home, I& i, bool depends=true); /// Remove from domain the values described by \a i template<class I> ModEvent minus_v(Space& home, I& i, bool depends=true); //@}
/// \name View-dependent propagator support //@{ /// Translate modification event \a me to modification event delta for view static ModEventDelta med(ModEvent me); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; //@} };
/** * \brief Print integer minus view * \relates Gecode::Int::MinusView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const MinusView& x);
/** \name View comparison * \relates Gecode::Int::MinusView */ //@{ /// Test whether views \a x and \a y are the same bool operator ==(const MinusView& x, const MinusView& y); /// Test whether views \a x and \a y are not the same bool operator !=(const MinusView& x, const MinusView& y); //@}
/** * \brief Offset integer view * * An offset integer view \f$o\f$ for an integer view \f$x\f$ and * an integer \f$c\f$ provides operations such that \f$o\f$ * behaves as \f$x+c\f$. * \ingroup TaskActorIntView */ class OffsetView : public DerivedView<IntView> { protected: /// Offset int c; using DerivedView<IntView>::x; public: /// \name Constructors and initialization //@{ /// Default constructor OffsetView(void); /// Initialize with integer view \a y and offset \a c OffsetView(const IntView& y, int c); //@}
/// \name Value access //@{ /// Return offset int offset(void) const; /// Change offset to \a n void offset(int n); /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return median of domain (greatest element not greater than the median) int med(void) const; /// Return assigned value (only if assigned) int val(void) const;#ifdef GECODE_HAS_CBS /// Return reverse transformation of value according to view int baseval(int val) const;#endif
/// Return size (cardinality) of domain unsigned int size(void) const; /// Return width of domain (distance between maximum and minimum) unsigned int width(void) const; /// Return regret of domain minimum (distance to next larger value) unsigned int regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) unsigned int regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const;
/// Test whether \a n is contained in domain bool in(int n) const; /// Test whether \a n is contained in domain bool in(long long int n) const; //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@}
/** * \name Domain update by iterator * * Views can be both updated by range and value iterators. * Value iterators do not need to be strict in that the same value * is allowed to occur more than once in the iterated sequence. * * The argument \a depends must be true, if the iterator * passed as argument depends on the view on which the operation * is invoked. In this case, the view is only updated after the * iterator has been consumed. Otherwise, the domain might be updated * concurrently while following the iterator. * */ //@{ /// Replace domain by ranges described by \a i template<class I> ModEvent narrow_r(Space& home, I& i, bool depends=true); /// Intersect domain with ranges described by \a i template<class I> ModEvent inter_r(Space& home, I& i, bool depends=true); /// Remove from domain the ranges described by \a i template<class I> ModEvent minus_r(Space& home, I& i, bool depends=true); /// Replace domain by values described by \a i template<class I> ModEvent narrow_v(Space& home, I& i, bool depends=true); /// Intersect domain with values described by \a i template<class I> ModEvent inter_v(Space& home, I& i, bool depends=true); /// Remove from domain the values described by \a i template<class I> ModEvent minus_v(Space& home, I& i, bool depends=true); //@}
/// \name View-dependent propagator support //@{ /// Translate modification event \a me to modification event delta for view static ModEventDelta med(ModEvent me); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; //@}
/// \name Cloning //@{ /// Update this view to be a clone of view \a y void update(Space& home, OffsetView& y); //@}
/// \name Ordering //@{ /// Whether this view comes before view \a y (arbitray order) bool operator <(const OffsetView& y) const; //@} };
/** * \brief Print integer offset view * \relates Gecode::Int::OffsetView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const OffsetView& x);
/** \name View comparison * \relates Gecode::Int::OffsetView */ //@{ /// Test whether views \a x and \a y are the same bool operator ==(const OffsetView& x, const OffsetView& y); /// Test whether views \a x and \a y are not the same bool operator !=(const OffsetView& x, const OffsetView& y); //@}
/** * \brief Converter without offsets */ template<class View> class NoOffset { public: /// The view type typedef View ViewType; /// Pass through \a x View& operator ()(View& x); /// Update during cloning void update(const NoOffset&); /// Access offset int offset(void) const; };
template<class View> forceinline View& NoOffset<View>::operator ()(View& x) { return x; }
template<class View> forceinline void NoOffset<View>::update(const NoOffset&) {}
template<class View> forceinline int NoOffset<View>::offset(void) const { return 0; }
/** * \brief Converter with fixed offset */ class Offset { public: /// The view type typedef OffsetView ViewType; /// The offset int c; /// Constructor with offset \a off Offset(int off = 0); /// Return OffsetRefView for \a x OffsetView operator()(IntView& x); /// Update during cloning void update(const Offset& o); /// Access offset int offset(void) const; };
forceinline Offset::Offset(int off) : c(off) {}
forceinline void Offset::update(const Offset& o) { c = o.c; }
forceinline int Offset::offset(void) const { return c; }
forceinline OffsetView Offset::operator ()(IntView& x) { return OffsetView(x,c); }
/** * \brief Scale integer view (template) * * A scale integer view \f$s\f$ for an integer view \f$x\f$ and * a non-negative integer \f$a\f$ provides operations such that \f$s\f$ * behaves as \f$a\cdot x\f$. * * The precision of a scale integer view is defined by the value types * \a Val and \a UnsVal. \a Val can be either \c int or \c long \c long * \c int where \a UnsVal must be the unsigned variant of \a Val. The * range which is allowed for the two types is defined by the values in * Gecode::Limits. * * Note that scale integer views currently do not provide operations * for updating domains by range iterators. * * The template is not to be used directly (as it is very clumsy). Use * the following instead: * - IntScaleView for scale views with integer precision * - LLongScaleView for scale views with long long precision * * \ingroup TaskActorIntView */ template<class Val, class UnsVal> class ScaleView : public DerivedView<IntView> { protected: using DerivedView<IntView>::x; /// Scale factor int a; public: /// \name Constructors and initialization //@{ /// Default constructor ScaleView(void); /// Initialize as \f$b\cdot y\f$ ScaleView(int b, const IntView& y); //@}
/// \name Value access //@{ /// Return scale factor of scale view int scale(void) const; /// Return minimum of domain Val min(void) const; /// Return maximum of domain Val max(void) const; /// Return median of domain (greatest element not greater than the median) Val med(void) const; /// Return assigned value (only if assigned) Val val(void) const;#ifdef GECODE_HAS_CBS /// Return reverse transformation of value according to view Val baseval(Val val) const;#endif
/// Return size (cardinality) of domain UnsVal size(void) const; /// Return width of domain (distance between maximum and minimum) UnsVal width(void) const; /// Return regret of domain minimum (distance to next larger value) UnsVal regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) UnsVal regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const; /// Test whether \a n is contained in domain bool in(Val n) const; //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, Val n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, Val n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, Val n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, Val n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, Val n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, Val n); //@}
/// \name View-dependent propagator support //@{ /// Translate modification event \a me to modification event delta for view static ModEventDelta med(ModEvent me); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned Val min(const Delta& d) const; /// Return maximum value just pruned Val max(const Delta& d) const; /// Return width of values just pruned UnsVal width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; //@}
/// \name Cloning //@{ /// Update this view to be a clone of view \a y void update(Space& home, ScaleView<Val,UnsVal>& y); //@}
/// \name Ordering //@{ /// Whether this view comes before view \a y (arbitray order) bool operator <(const ScaleView<Val,UnsVal>& y) const; //@} };
/** * \brief Integer-precision integer scale view * \ingroup TaskActorIntView */ typedef ScaleView<int,unsigned int> IntScaleView;
/** * \brief Long long-precision integer scale view * \ingroup TaskActorIntView */ typedef ScaleView<long long int,unsigned long long int> LLongScaleView;
/** * \brief Print integer-precision integer scale view * \relates Gecode::Int::ScaleView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const IntScaleView& x);
/** * \brief Print long long-precision integer scale view * \relates Gecode::Int::ScaleView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const LLongScaleView& x);
/** \name View comparison * \relates Gecode::Int::ScaleView */ //@{ /// Test whether views \a x and \a y are the same template<class Val, class UnsVal> bool operator ==(const ScaleView<Val,UnsVal>& x, const ScaleView<Val,UnsVal>& y); /// Test whether views \a x and \a y are not the same template<class Val, class UnsVal> bool operator !=(const ScaleView<Val,UnsVal>& x, const ScaleView<Val,UnsVal>& y); //@}
/** * \brief Constant integer view * * A constant integer view \f$x\f$ for an integer \f$c\f$ provides * operations such that \f$x\f$ behaves as a view assigned to \f$c\f$. * \ingroup TaskActorIntView */ class ConstIntView : public ConstView<IntView> { protected: int x; public: /// \name Constructors and initialization //@{ /// Default constructor ConstIntView(void); /// Initialize with integer value \a n ConstIntView(int n); //@}
/// \name Value access //@{ /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return median of domain (greatest element not greater than the median) int med(void) const; /// Return assigned value (only if assigned) int val(void) const;
/// Return size (cardinality) of domain unsigned int size(void) const; /// Return width of domain (distance between maximum and minimum) unsigned int width(void) const; /// Return regret of domain minimum (distance to next larger value) unsigned int regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) unsigned int regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const; /// Test whether \a n is contained in domain bool in(int n) const; /// Test whether \a n is contained in domain bool in(long long int n) const; //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@}
/** * \name Domain update by iterator * * Views can be both updated by range and value iterators. * Value iterators do not need to be strict in that the same value * is allowed to occur more than once in the iterated sequence. * * The argument \a depends must be true, if the iterator * passed as argument depends on the view on which the operation * is invoked. In this case, the view is only updated after the * iterator has been consumed. Otherwise, the domain might be updated * concurrently while following the iterator. * */ //@{ /// Replace domain by ranges described by \a i template<class I> ModEvent narrow_r(Space& home, I& i, bool depends=true); /// Intersect domain with ranges described by \a i template<class I> ModEvent inter_r(Space& home, I& i, bool depends=true); /// Remove from domain the ranges described by \a i template<class I> ModEvent minus_r(Space& home, I& i, bool depends=true); /// Replace domain by values described by \a i template<class I> ModEvent narrow_v(Space& home, I& i, bool depends=true); /// Intersect domain with values described by \a i template<class I> ModEvent inter_v(Space& home, I& i, bool depends=true); /// Remove from domain the values described by \a i template<class I> ModEvent minus_v(Space& home, I& i, bool depends=true); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; //@}
/// \name Cloning //@{ /// Update this view to be a clone of view \a y void update(Space& home, ConstIntView& y); //@}
/// \name Ordering //@{ /// Whether this view comes before view \a y (arbitray order) bool operator <(const ConstIntView& y) const; //@} };
/** * \brief Print integer constant integer view * \relates Gecode::Int::ConstIntView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const ConstIntView& x);
/** * \name View comparison * \relates Gecode::Int::ConstIntView */ //@{ /// Test whether views \a x and \a y are the same bool operator ==(const ConstIntView& x, const ConstIntView& y); /// Test whether views \a x and \a y are not the same bool operator !=(const ConstIntView& x, const ConstIntView& y); //@}
/** * \brief Zero integer view * * A zero integer view \f$x\f$ for provides * operations such that \f$x\f$ behaves as a view assigned to \f$0\f$. * \ingroup TaskActorIntView */ class ZeroIntView : public ConstView<IntView> { public: /// \name Constructors and initialization //@{ /// Default constructor ZeroIntView(void); //@}
/// \name Value access //@{ /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return median of domain (greatest element not greater than the median) int med(void) const; /// Return assigned value (only if assigned) int val(void) const;
/// Return size (cardinality) of domain unsigned int size(void) const; /// Return width of domain (distance between maximum and minimum) unsigned int width(void) const; /// Return regret of domain minimum (distance to next larger value) unsigned int regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) unsigned int regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const; /// Test whether \a n is contained in domain bool in(int n) const; /// Test whether \a n is contained in domain bool in(long long int n) const; //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@}
/** * \name Domain update by iterator * * Views can be both updated by range and value iterators. * Value iterators do not need to be strict in that the same value * is allowed to occur more than once in the iterated sequence. * * The argument \a depends must be true, if the iterator * passed as argument depends on the view on which the operation * is invoked. In this case, the view is only updated after the * iterator has been consumed. Otherwise, the domain might be updated * concurrently while following the iterator. * */ //@{ /// Replace domain by ranges described by \a i template<class I> ModEvent narrow_r(Space& home, I& i, bool depends=true); /// Intersect domain with ranges described by \a i template<class I> ModEvent inter_r(Space& home, I& i, bool depends=true); /// Remove from domain the ranges described by \a i template<class I> ModEvent minus_r(Space& home, I& i, bool depends=true); /// Replace domain by values described by \a i template<class I> ModEvent narrow_v(Space& home, I& i, bool depends=true); /// Intersect domain with values described by \a i template<class I> ModEvent inter_v(Space& home, I& i, bool depends=true); /// Remove from domain the values described by \a i template<class I> ModEvent minus_v(Space& home, I& i, bool depends=true); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; //@} };
/** * \brief Print integer zero view * \relates Gecode::Int::ZeroView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const ZeroIntView& x);
/** * \name View comparison * \relates Gecode::Int::ZeroIntView */ //@{ /// Test whether views \a x and \a y are the same bool operator ==(const ZeroIntView& x, const ZeroIntView& y); /// Test whether views \a x and \a y are the same bool operator !=(const ZeroIntView& x, const ZeroIntView& y); //@}
template<class View> class ViewDiffRanges;
/** * \brief Cached integer view * * A cached integer view \f$c\f$ for an integer view \f$x\f$ adds operations * for cacheing the current domain of \f$x\f$ and comparing the current * domain to the cached domain. Cached views make it easy to implement * incremental propagation algorithms. * * \ingroup TaskActorIntView */ template<class View> class CachedView : public DerivedView<View> { friend class ViewDiffRanges<View>; protected: using DerivedView<View>::x; /// First cached range RangeList* _firstRange; /// Last cached range RangeList* _lastRange; /// Size of cached domain unsigned int _size; public: /// \name Constructors and initialization //@{ /// Default constructor CachedView(void); /// Initialize with integer view \a y explicit CachedView(const View& y); //@}
/// \name Value access //@{ /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return median of domain (greatest element not greater than the median) int med(void) const; /// Return assigned value (only if assigned) int val(void) const;#ifdef GECODE_HAS_CBS /// Return reverse transformation of value according to view int baseval(int val) const;#endif
/// Return size (cardinality) of domain unsigned int size(void) const; /// Return width of domain (distance between maximum and minimum) unsigned int width(void) const; /// Return regret of domain minimum (distance to next larger value) unsigned int regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) unsigned int regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const;
/// Test whether \a n is contained in domain bool in(int n) const; /// Test whether \a n is contained in domain bool in(long long int n) const; //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@}
/** * \name Domain update by iterator * * Views can be both updated by range and value iterators. * Value iterators do not need to be strict in that the same value * is allowed to occur more than once in the iterated sequence. * * The argument \a depends must be true, if the iterator * passed as argument depends on the view on which the operation * is invoked. In this case, the view is only updated after the * iterator has been consumed. Otherwise, the domain might be updated * concurrently while following the iterator. * */ //@{ /// Replace domain by ranges described by \a i template<class I> ModEvent narrow_r(Space& home, I& i, bool depends=true); /// Intersect domain with ranges described by \a i template<class I> ModEvent inter_r(Space& home, I& i, bool depends=true); /// Remove from domain the ranges described by \a i template<class I> ModEvent minus_r(Space& home, I& i, bool depends=true); /// Replace domain by values described by \a i template<class I> ModEvent narrow_v(Space& home, I& i, bool depends=true); /// Intersect domain with values described by \a i template<class I> ModEvent inter_v(Space& home, I& i, bool depends=true); /// Remove from domain the values described by \a i template<class I> ModEvent minus_v(Space& home, I& i, bool depends=true); //@}
/// \name View-dependent propagator support //@{ /// Translate modification event \a me to modification event delta for view static ModEventDelta med(ModEvent me); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; //@}
/// \name Domain cache operations //@{ /// Initialize cache to set \a s void initCache(Space& home, const IntSet& s); /// Update cache to current domain void cache(Space& home); /// Check whether cache differs from current domain bool modified(void) const; //@}
/// \name Cloning //@{ /// Update this view to be a clone of view \a y void update(Space& home, CachedView<View>& y); //@} };
/** * \brief Print integer cached view * \relates Gecode::Int::CachedView */ template<class Char, class Traits, class View> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const CachedView<View>& x);
/** \name View comparison * \relates Gecode::Int::CachedView */ //@{ /// Test whether views \a x and \a y are the same template<class View> bool operator ==(const CachedView<View>& x, const CachedView<View>& y); /// Test whether views \a x and \a y are not the same template<class View> bool operator !=(const CachedView<View>& x, const CachedView<View>& y); //@}
/** * \brief %Range iterator for cached integer views * * This iterator iterates the difference between the cached domain * and the current domain of an integer view. * * \ingroup TaskActorInt */ template<class View> class ViewDiffRanges : public Iter::Ranges::Diff<Iter::Ranges::RangeList,ViewRanges<View> > { typedef Iter::Ranges::Diff<Iter::Ranges::RangeList,ViewRanges<View> > Super; protected: /// Cached domain iterator Iter::Ranges::RangeList cr; /// Current domain iterator ViewRanges<View> dr; public: /// \name Constructors and initialization //@{ /// Default constructor ViewDiffRanges(void); /// Initialize with ranges for view \a x ViewDiffRanges(const CachedView<View>& x); /// Initialize with ranges for view \a x void init(const CachedView<View>& x); //@} };
/** * \brief Boolean view for Boolean variables * * Provides convenient and efficient operations for Boolean views. * \ingroup TaskActorIntView */ class BoolView : public VarImpView<BoolVar> { protected: using VarImpView<BoolVar>::x; public: /// \name Constructors and initialization //@{ /// Default constructor BoolView(void); /// Initialize from Boolean variable \a y BoolView(const BoolVar& y); /// Initialize from Boolean variable implementation \a y BoolView(BoolVarImp* y); //@}
/// \name Domain status access //@{ /// How many bits does the status have static const int BITS = BoolVarImp::BITS; /// Status of domain assigned to zero static const BoolStatus ZERO = BoolVarImp::ZERO; /// Status of domain assigned to one static const BoolStatus ONE = BoolVarImp::ONE; /// Status of domain not yet assigned static const BoolStatus NONE = BoolVarImp::NONE; /// Return current domain status BoolStatus status(void) const; //@}
/// \name Value access //@{ /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return median of domain (greatest element not greater than the median) int med(void) const; /// Return assigned value (only if assigned) int val(void) const;#ifdef GECODE_HAS_CBS /// Return reverse transformation of value according to view int baseval(int val) const;#endif
/// Return size (cardinality) of domain unsigned int size(void) const; /// Return width of domain (distance between maximum and minimum) unsigned int width(void) const; /// Return regret of domain minimum (distance to next larger value) unsigned int regret_min(void) const; /// Return regret of domain maximum (distance to next smaller value) unsigned int regret_max(void) const; //@}
/// \name Domain tests //@{ /// Test whether domain is a range bool range(void) const; /// Test whether \a n is contained in domain bool in(int n) const; /// Test whether \a n is contained in domain bool in(long long int n) const; //@}
/// \name Boolean domain tests //@{ /// Test whether view is assigned to be zero bool zero(void) const; /// Test whether view is assigned to be one bool one(void) const; /// Test whether view is not yet assigned bool none(void) const; //@}
/// \name Boolean assignment operations //@{ /// Try to assign view to one ModEvent one(Space& home); /// Try to assign view to zero ModEvent zero(Space& home); /// Assign not yet assigned view to one ModEvent one_none(Space& home); /// Assign not yet assigned view to zero ModEvent zero_none(Space& home); //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@}
/** * \name Domain update by iterator * * Views can be both updated by range and value iterators. * Value iterators do not need to be strict in that the same value * is allowed to occur more than once in the iterated sequence. * * The argument \a depends must be true, if the iterator * passed as argument depends on the view on which the operation * is invoked. In this case, the view is only updated after the * iterator has been consumed. Otherwise, the domain might be updated * concurrently while following the iterator. * */ //@{ /// Replace domain by ranges described by \a i template<class I> ModEvent narrow_r(Space& home, I& i, bool depends=true); /// Intersect domain with ranges described by \a i template<class I> ModEvent inter_r(Space& home, I& i, bool depends=true); /// Remove from domain the ranges described by \a i template<class I> ModEvent minus_r(Space& home, I& i, bool depends=true); /// Replace domain by values described by \a i template<class I> ModEvent narrow_v(Space& home, I& i, bool depends=true); /// Intersect domain with values described by \a i template<class I> ModEvent inter_v(Space& home, I& i, bool depends=true); /// Remove from domain the values described by \a i template<class I> ModEvent minus_v(Space& home, I& i, bool depends=true); //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; /// Test whether a view has been assigned to zero static bool zero(const Delta& d); /// Test whether a view has been assigned to one static bool one(const Delta& d); //@}
/// \name View-dependent propagator support //@{ /// Translate modification event \a me to modification event delta for view static ModEventDelta med(ModEvent me); //@} };
/** * \brief Print Boolean view * \relates Gecode::Int::BoolView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const BoolView& x);
/** * \brief Negated Boolean view * * A negated Boolean view \f$n\f$ for a Boolean view \f$b\f$ * provides operations such that \f$n\f$ * behaves as \f$\neg b\f$. * \ingroup TaskActorIntView */ class NegBoolView : public DerivedView<BoolView> { protected: using DerivedView<BoolView>::x; public: /// \name Constructors and initialization //@{ /// Default constructor NegBoolView(void); /// Initialize with Boolean view \a y explicit NegBoolView(const BoolView& y); //@}
/// \name Domain status access //@{ /// How many bits does the status have static const int BITS = BoolView::BITS; /// Status of domain assigned to zero static const BoolStatus ZERO = BoolView::ONE; /// Status of domain assigned to one static const BoolStatus ONE = BoolView::ZERO; /// Status of domain not yet assigned static const BoolStatus NONE = BoolView::NONE; /// Return current domain status BoolStatus status(void) const; //@}
/// \name Boolean domain tests //@{ /// Test whether view is assigned to be zero bool zero(void) const; /// Test whether view is assigned to be one bool one(void) const; /// Test whether view is not yet assigned bool none(void) const; //@}
/// \name Boolean assignment operations //@{ /// Try to assign view to one ModEvent one(Space& home); /// Try to assign view to zero ModEvent zero(Space& home); /// Assign not yet assigned view to one ModEvent one_none(Space& home); /// Assign not yet assigned view to zero ModEvent zero_none(Space& home); //@}
/// \name Domain update by value //@{ /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, int n); /// Restrict domain values to be less or equal than \a n ModEvent lq(Space& home, long long int n);
/// Restrict domain values to be less than \a n ModEvent le(Space& home, int n); /// Restrict domain values to be less than \a n ModEvent le(Space& home, long long int n);
/// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, int n); /// Restrict domain values to be greater or equal than \a n ModEvent gq(Space& home, long long int n);
/// Restrict domain values to be greater than \a n ModEvent gr(Space& home, int n); /// Restrict domain values to be greater than \a n ModEvent gr(Space& home, long long int n);
/// Restrict domain values to be different from \a n ModEvent nq(Space& home, int n); /// Restrict domain values to be different from \a n ModEvent nq(Space& home, long long int n);
/// Restrict domain values to be equal to \a n ModEvent eq(Space& home, int n); /// Restrict domain values to be equal to \a n ModEvent eq(Space& home, long long int n); //@} /// \name Value access //@{ /// Return minimum of domain int min(void) const; /// Return maximum of domain int max(void) const; /// Return assigned value (only if assigned) int val(void) const;#ifdef GECODE_HAS_CBS /// Return reverse transformation of value according to view int baseval(int val) const;#endif //@}
/// \name Delta information for advisors //@{ /// Return minimum value just pruned int min(const Delta& d) const; /// Return maximum value just pruned int max(const Delta& d) const; /// Return width of values just pruned unsigned int width(const Delta& d) const; /// Test whether arbitrary values got pruned bool any(const Delta& d) const; /// Test whether a view has been assigned to zero static bool zero(const Delta& d); /// Test whether a view has been assigned to one static bool one(const Delta& d); //@} };
/** \name View comparison * \relates Gecode::Int::NegBoolView */ //@{ /// Test whether views \a x and \a y are the same bool operator ==(const NegBoolView& x, const NegBoolView& y); /// Test whether views \a x and \a y are not the same bool operator !=(const NegBoolView& x, const NegBoolView& y); //@}
/** * \brief Print negated Boolean view * \relates Gecode::Int::NegBoolView */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const NegBoolView& x);
}}
#include <gecode/int/var/int.hpp>#include <gecode/int/var/bool.hpp>
#include <gecode/int/view/int.hpp>
#include <gecode/int/view/constint.hpp>#include <gecode/int/view/zero.hpp>#include <gecode/int/view/minus.hpp>#include <gecode/int/view/offset.hpp>#include <gecode/int/view/scale.hpp>#include <gecode/int/view/cached.hpp>
#include <gecode/int/view/bool.hpp>
#include <gecode/int/view/neg-bool.hpp>
#include <gecode/int/view/print.hpp>#include <gecode/int/var/print.hpp>
namespace Gecode { namespace Int {
/** * \defgroup TaskActorIntTest Testing relations between integer views * \ingroup TaskActorInt */
//@{ /// Result of testing relation enum RelTest { RT_FALSE = 0, ///< Relation does not hold RT_MAYBE = 1, ///< Relation may hold or not RT_TRUE = 2 ///< Relation does hold };
/// Test whether views \a x and \a y are equal (use bounds information) template<class VX, class VY> RelTest rtest_eq_bnd(VX x, VY y); /// Test whether views \a x and \a y are equal (use full domain information) template<class VX, class VY> RelTest rtest_eq_dom(VX x, VY y); /// Test whether view \a x and integer \a n are equal (use bounds information) template<class VX> RelTest rtest_eq_bnd(VX x, int n); /// Test whether view \a x and integer \a n are equal (use full domain information) template<class VX> RelTest rtest_eq_dom(VX x, int n);
/// Test whether views \a x and \a y are different (use bounds information) template<class VX, class VY> RelTest rtest_nq_bnd(VX x, VY y); /// Test whether views \a x and \a y are different (use full domain information) template<class VX, class VY> RelTest rtest_nq_dom(VX x, VY y); /// Test whether view \a x and integer \a n are different (use bounds information) template<class VX> RelTest rtest_nq_bnd(VX x, int n); /// Test whether view \a x and integer \a n are different (use full domain information) template<class VX> RelTest rtest_nq_dom(VX x, int n);
/// Test whether view \a x is less or equal than view \a y template<class VX, class VY> RelTest rtest_lq(VX x, VY y); /// Test whether view \a x is less or equal than integer \a n template<class VX> RelTest rtest_lq(VX x, int n);
/// Test whether view \a x is less than view \a y template<class VX, class VY> RelTest rtest_le(VX x, VY y); /// Test whether view \a x is less than integer \a n template<class VX> RelTest rtest_le(VX x, int n);
/// Test whether view \a x is greater or equal than view \a y template<class VX, class VY> RelTest rtest_gq(VX x, VY y); /// Test whether view \a x is greater or equal than integer \a n template<class VX> RelTest rtest_gq(VX x, int n);
/// Test whether view \a x is greater than view \a y template<class VX, class VY> RelTest rtest_gr(VX x, VY y); /// Test whether view \a x is greater than integer \a n template<class VX> RelTest rtest_gr(VX x, int n); //@}
/** * \brief Boolean tests * */ enum BoolTest { BT_NONE, ///< No sharing BT_SAME, ///< Same variable BT_COMP ///< Same variable but complement };
/** * \name Test sharing between Boolean and negated Boolean views * \relates BoolView NegBoolView */ //@{ /// Test whether views \a b0 and \a b1 are the same BoolTest bool_test(const BoolView& b0, const BoolView& b1); /// Test whether views \a b0 and \a b1 are complementary BoolTest bool_test(const BoolView& b0, const NegBoolView& b1); /// Test whether views \a b0 and \a b1 are complementary BoolTest bool_test(const NegBoolView& b0, const BoolView& b1); /// Test whether views \a b0 and \a b1 are the same BoolTest bool_test(const NegBoolView& b0, const NegBoolView& b1); //@}
}}
#include <gecode/int/view/rel-test.hpp>#include <gecode/int/view/bool-test.hpp>
// STATISTICS: int-var