Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
90 kB · 2497 lines
C++
at develop
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- *//* * Main authors: * Christian Schulte <schulte@gecode.org> * Guido Tack <tack@gecode.org> * Matthias Balzer <matthias.balzer@itwm.fraunhofer.de> * Mikael Lagerkvist <lagerkvist@gecode.org> * Vincent Barichard <Vincent.Barichard@univ-angers.fr> * * Copyright: * Christian Schulte, 2004 * Fraunhofer ITWM, 2017 * Guido Tack, 2004 * Mikael Lagerkvist, 2005 * Vincent Barichard, 2012 * * 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. * */
#ifndef GECODE_MINIMODEL_HH#define GECODE_MINIMODEL_HH
#include <gecode/kernel.hh>#include <gecode/int.hh>#ifdef GECODE_HAS_SET_VARS#include <gecode/set.hh>#endif#ifdef GECODE_HAS_FLOAT_VARS#include <gecode/float.hh>#endif
#include <iostream>
/* * Support for DLLs under Windows * */
#if !defined(GECODE_STATIC_LIBS) && \ (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
#ifdef GECODE_BUILD_MINIMODEL#define GECODE_MINIMODEL_EXPORT __declspec( dllexport )#else#define GECODE_MINIMODEL_EXPORT __declspec( dllimport )#endif
#else
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
#define GECODE_MINIMODEL_EXPORT __attribute__ ((visibility("default")))
#else
#define GECODE_MINIMODEL_EXPORT
#endif#endif
// Configure auto-linking#ifndef GECODE_BUILD_MINIMODEL#define GECODE_LIBRARY_NAME "MiniModel"#include <gecode/support/auto-link.hpp>#endif
namespace Gecode {
/// Minimalistic modeling support namespace MiniModel {}
}
#include <gecode/minimodel/exception.hpp>
namespace Gecode {
/// Class for specifying integer propagation levels used by minimodel class IntPropLevels { protected: IntPropLevel _linear2 : IPL_BITS_; ///< For binary linear IntPropLevel _linear : IPL_BITS_; ///< For n-ary linear IntPropLevel _abs : IPL_BITS_; ///< For absolute value IntPropLevel _max2 : IPL_BITS_; ///< For binary maximum IntPropLevel _max : IPL_BITS_; ///< For n-ary maximum IntPropLevel _min2 : IPL_BITS_; ///< For binary minimum IntPropLevel _min : IPL_BITS_; ///< For minimum IntPropLevel _mult : IPL_BITS_; ///< For multiplication IntPropLevel _div : IPL_BITS_; ///< For division IntPropLevel _mod : IPL_BITS_; ///< For modulo IntPropLevel _sqr : IPL_BITS_; ///< For square IntPropLevel _sqrt : IPL_BITS_; ///< For square root IntPropLevel _pow : IPL_BITS_; ///< For power IntPropLevel _nroot : IPL_BITS_; ///< For root IntPropLevel _element : IPL_BITS_; ///< For element IntPropLevel _ite : IPL_BITS_; ///< For if-then-else public: /// Initialize with default propagation level IntPropLevels(IntPropLevel ipl=IPL_DEF);
/// Return integer propagation level for binary linear constraints IntPropLevel linear2(void) const; /// Set integer propagation level for binary linear constraints IntPropLevels& linear2(IntPropLevel ipl); /// Return integer propagation level for non-binary linear constraints IntPropLevel linear(void) const; /// Set integer propagation level for non-binary linear constraints IntPropLevels& linear(IntPropLevel ipl);
/// Return integer propagation level for absolute value constraints IntPropLevel abs(void) const; /// Set integer propagation level for absolute value constraints IntPropLevels& abs(IntPropLevel ipl);
/// Return integer propagation level for binary maximum constraints IntPropLevel max2(void) const; /// Set integer propagation level for binary maximum constraints IntPropLevels& max2(IntPropLevel ipl); /// Return integer propagation level for non-binary maximum constraints IntPropLevel max(void) const; /// Set integer propagation level for non-binary maximum constraints IntPropLevels& max(IntPropLevel ipl); /// Return integer propagation level for binary minimum constraints IntPropLevel min2(void) const; /// Set integer propagation level for binary minimum constraints IntPropLevels& min2(IntPropLevel ipl); /// Return integer propagation level for non-binary minimum constraints IntPropLevel min(void) const; /// Set integer propagation level for non-binary minimum constraints IntPropLevels& min(IntPropLevel ipl);
/// Return integer propagation level for multiplication constraints IntPropLevel mult(void) const; /// Set integer propagation level for multiplication constraints IntPropLevels& mult(IntPropLevel ipl); /// Return integer propagation level for division constraints IntPropLevel div(void) const; /// Set integer propagation level for division constraints IntPropLevels& div(IntPropLevel ipl); /// Return integer propagation level for modulo constraints IntPropLevel mod(void) const; /// Set integer propagation level for modulo constraints IntPropLevels& mod(IntPropLevel ipl);
/// Return integer propagation level for square constraints IntPropLevel sqr(void) const; /// Set integer propagation level for square constraints IntPropLevels& sqr(IntPropLevel ipl); /// Return integer propagation level for square root constraints IntPropLevel sqrt(void) const; /// Set integer propagation level for square root constraints IntPropLevels& sqrt(IntPropLevel ipl);
/// Return integer propagation level for power constraints IntPropLevel pow(void) const; /// Set integer propagation level for power constraints IntPropLevels& pow(IntPropLevel ipl); /// Return integer propagation level for root constraints IntPropLevel nroot(void) const; /// Set integer propagation level for root constraints IntPropLevels& nroot(IntPropLevel ipl);
/// Return integer propagation level for element constraints IntPropLevel element(void) const; /// Set integer propagation level for element constraints IntPropLevels& element(IntPropLevel ipl);
/// Return integer propagation level for if-then-else constraints IntPropLevel ite(void) const; /// Set integer propagation level for if-then-else constraints IntPropLevels& ite(IntPropLevel ipl);
/// Default propagation levels for all constraints GECODE_MINIMODEL_EXPORT static const IntPropLevels def; };
}
#include <gecode/minimodel/ipl.hpp>
namespace Gecode {
class LinIntRel;#ifdef GECODE_HAS_SET_VARS class SetExpr;#endif#ifdef GECODE_HAS_FLOAT_VARS class LinFloatExpr;#endif
/// Base class for non-linear expressions over integer variables class NonLinIntExpr { public: /// Return variable constrained to be equal to the expression virtual IntVar post(Home home, IntVar* ret, const IntPropLevels& ipls) const = 0; /// Post expression to be in relation \a irt with \a c virtual void post(Home home, IntRelType irt, int c, const IntPropLevels& ipls) const = 0; /// Post reified expression to be in relation \a irt with \a c virtual void post(Home home, IntRelType irt, int c, BoolVar b, const IntPropLevels& ipls) const = 0; /// Destructor virtual ~NonLinIntExpr(void); /// Return fresh variable if \a x is null, \a x otherwise static IntVar result(Home home, IntVar* x); /// Constrain \a x to be equal to \a y if \a x is not null static IntVar result(Home home, IntVar* x, IntVar y); /// Memory management void* operator new(size_t s); /// Memory management void operator delete(void* p, size_t s); };
}
#include <gecode/minimodel/int-expr.hpp>
namespace Gecode {
/// Linear expressions over integer variables class LinIntExpr { friend class LinIntRel;#ifdef GECODE_HAS_SET_VARS friend class SetExpr;#endif#ifdef GECODE_HAS_FLOAT_VARS friend class LinFloatExpr;#endif public: /// Type of linear expression enum NodeType { NT_CONST, ///< Integer constant NT_VAR_INT, ///< Linear term with integer variable NT_VAR_BOOL, ///< Linear term with Boolean variable NT_NONLIN, ///< Non-linear expression NT_SUM_INT, ///< Sum of integer variables NT_SUM_BOOL, ///< Sum of Boolean variables NT_ADD, ///< Addition of linear terms NT_SUB, ///< Subtraction of linear terms NT_MUL ///< Multiplication by coefficient }; private: /// Nodes for linear expressions class Node; /// The actual node Node* n; public: /// Default constructor GECODE_MINIMODEL_EXPORT LinIntExpr(void); /// Create expression for constant \a c GECODE_MINIMODEL_EXPORT LinIntExpr(int c); /// Create expression GECODE_MINIMODEL_EXPORT LinIntExpr(const IntVar& x, int a=1); /// Create expression GECODE_MINIMODEL_EXPORT LinIntExpr(const BoolVar& x, int a=1); /// Create sum expression GECODE_MINIMODEL_EXPORT explicit LinIntExpr(const IntVarArgs& x); /// Create sum expression GECODE_MINIMODEL_EXPORT LinIntExpr(const IntArgs& a, const IntVarArgs& x); /// Create sum expression GECODE_MINIMODEL_EXPORT explicit LinIntExpr(const BoolVarArgs& x); /// Create sum expression GECODE_MINIMODEL_EXPORT LinIntExpr(const IntArgs& a, const BoolVarArgs& x); /// Copy constructor GECODE_MINIMODEL_EXPORT LinIntExpr(const LinIntExpr& e); /// Create expression for type and subexpressions GECODE_MINIMODEL_EXPORT LinIntExpr(const LinIntExpr& e0, NodeType t, const LinIntExpr& e1); /// Create expression for type and subexpression GECODE_MINIMODEL_EXPORT LinIntExpr(const LinIntExpr& e0, NodeType t, int c); /// Create expression for multiplication GECODE_MINIMODEL_EXPORT LinIntExpr(int a, const LinIntExpr& e); /// Create non-linear expression GECODE_MINIMODEL_EXPORT explicit LinIntExpr(NonLinIntExpr* e); /// Assignment operator GECODE_MINIMODEL_EXPORT const LinIntExpr& operator =(const LinIntExpr& e); /// Post propagator GECODE_MINIMODEL_EXPORT void post(Home home, IntRelType irt, const IntPropLevels& ipls) const; /// Post reified propagator GECODE_MINIMODEL_EXPORT void post(Home home, IntRelType irt, const BoolVar& b, const IntPropLevels& ipls) const; /// Post propagator and return variable for value GECODE_MINIMODEL_EXPORT IntVar post(Home home, const IntPropLevels& ipls) const; /// Return non-linear expression inside, or null if not non-linear GECODE_MINIMODEL_EXPORT NonLinIntExpr* nle(void) const; /// Destructor GECODE_MINIMODEL_EXPORT ~LinIntExpr(void); };
class BoolExpr;
/// Linear relations over integer variables class LinIntRel { friend class BoolExpr; private: /// Linear expression describing the entire relation LinIntExpr e; /// Which relation IntRelType irt; /// Negate relation type static IntRelType neg(IntRelType irt); /// Default constructor LinIntRel(void); public: /// Create linear relation for expressions \a l and \a r LinIntRel(const LinIntExpr& l, IntRelType irt, const LinIntExpr& r); /// Create linear relation for expression \a l and integer \a r LinIntRel(const LinIntExpr& l, IntRelType irt, int r); /// Create linear relation for integer \a l and expression \a r LinIntRel(int l, IntRelType irt, const LinIntExpr& r); /// Post propagator for relation (if \a t is false for negated relation) void post(Home home, bool t, const IntPropLevels& ipls) const; /// Post reified propagator for relation (if \a t is false for negated relation) void post(Home home, const BoolVar& b, bool t, const IntPropLevels& ipls) const; };
/** * \defgroup TaskModelMiniModelLin Linear expressions and relations * * Linear expressions can be freely composed of sums and differences of * integer variables (Gecode::IntVar) or Boolean variables * (Gecode::BoolVar) possibly with integer coefficients and integer * constants. * * Note that both integer and Boolean variables are automatically * available as linear expressions. * * Linear relations are obtained from linear expressions with the normal * relation operators. * * \ingroup TaskModelMiniModel */
//@{ /// Construct linear expression as sum of integer variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator +(int, const IntVar&); /// Construct linear expression as sum of Boolean variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator +(int, const BoolVar&); /// Construct linear expression as sum of linear expression and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator +(int, const LinIntExpr&); /// Construct linear expression as sum of integer variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const IntVar&, int); /// Construct linear expression as sum of Boolean variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const BoolVar&, int); /// Construct linear expression as sum of linear expression and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const LinIntExpr&, int); /// Construct linear expression as sum of integer variables GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const IntVar&, const IntVar&); /// Construct linear expression as sum of integer and Boolean variable GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const IntVar&, const BoolVar&); /// Construct linear expression as sum of Boolean and integer variable GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const BoolVar&, const IntVar&); /// Construct linear expression as sum of Boolean variables GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const BoolVar&, const BoolVar&); /// Construct linear expression as sum of integer variable and linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const IntVar&, const LinIntExpr&); /// Construct linear expression as sum of Boolean variable and linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const BoolVar&, const LinIntExpr&); /// Construct linear expression as sum of linear expression and integer variable GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const LinIntExpr&, const IntVar&); /// Construct linear expression as sum of linear expression and Boolean variable GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const LinIntExpr&, const BoolVar&); /// Construct linear expression as sum of linear expressions GECODE_MINIMODEL_EXPORT LinIntExpr operator +(const LinIntExpr&, const LinIntExpr&);
/// Construct linear expression as sum of integer variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator -(int, const IntVar&); /// Construct linear expression as sum of Boolean variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator -(int, const BoolVar&); /// Construct linear expression as sum of integer and linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator -(int, const LinIntExpr&); /// Construct linear expression as sum of integer variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const IntVar&, int); /// Construct linear expression as sum of Boolean variable and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const BoolVar&, int); /// Construct linear expression as sum of linear expression and integer GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const LinIntExpr&, int); /// Construct linear expression as sum of integer variables GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const IntVar&, const IntVar&); /// Construct linear expression as sum of integer and Boolean variable GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const IntVar&, const BoolVar&); /// Construct linear expression as sum of Boolean and integer variable GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const BoolVar&, const IntVar&); /// Construct linear expression as sum of Boolean variables GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const BoolVar&, const BoolVar&); /// Construct linear expression as sum of integer variable and linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const IntVar&, const LinIntExpr&); /// Construct linear expression as sum of Boolean variable and linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const BoolVar&, const LinIntExpr&); /// Construct linear expression as sum of linear expression and integer variable GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const LinIntExpr&, const IntVar&); /// Construct linear expression as sum of linear expression and Boolean variable GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const LinIntExpr&, const BoolVar&); /// Construct linear expression as sum of linear expressions GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const LinIntExpr&, const LinIntExpr&);
/// Construct linear expression as negative of integer variable GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const IntVar&); /// Construct linear expression as negative of Boolean variable GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const BoolVar&); /// Construct linear expression as negative of linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator -(const LinIntExpr&);
/// Construct linear expression as product of integer coefficient and integer variable GECODE_MINIMODEL_EXPORT LinIntExpr operator *(int, const IntVar&); /// Construct linear expression as product of integer coefficient and Boolean variable GECODE_MINIMODEL_EXPORT LinIntExpr operator *(int, const BoolVar&); /// Construct linear expression as product of integer coefficient and integer variable GECODE_MINIMODEL_EXPORT LinIntExpr operator *(const IntVar&, int); /// Construct linear expression as product of integer coefficient and Boolean variable GECODE_MINIMODEL_EXPORT LinIntExpr operator *(const BoolVar&, int); /// Construct linear expression as product of integer coefficient and linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator *(const LinIntExpr&, int); /// Construct linear expression as product of integer coefficient and linear expression GECODE_MINIMODEL_EXPORT LinIntExpr operator *(int, const LinIntExpr&);
/// Construct linear expression as sum of integer variables GECODE_MINIMODEL_EXPORT LinIntExpr sum(const IntVarArgs& x); /// Construct linear expression as sum of integer variables with coefficients GECODE_MINIMODEL_EXPORT LinIntExpr sum(const IntArgs& a, const IntVarArgs& x); /// Construct linear expression as sum of Boolean variables GECODE_MINIMODEL_EXPORT LinIntExpr sum(const BoolVarArgs& x); /// Construct linear expression as sum of Boolean variables with coefficients GECODE_MINIMODEL_EXPORT LinIntExpr sum(const IntArgs& a, const BoolVarArgs& x); /// Construct linear expression as sum of \ref IntArgs GECODE_MINIMODEL_EXPORT LinIntExpr sum(const IntArgs& args);
/// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(int l, const IntVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(int l, const BoolVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(int l, const LinIntExpr& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const IntVar& l, int r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const BoolVar& l, int r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const LinIntExpr& l, int r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const IntVar& l, const IntVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const IntVar& l, const BoolVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const BoolVar& l, const IntVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const BoolVar& l, const BoolVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const IntVar& l, const LinIntExpr& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const BoolVar& l, const LinIntExpr& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const LinIntExpr& l, const IntVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const LinIntExpr& l, const BoolVar& r); /// Construct linear equality relation GECODE_MINIMODEL_EXPORT LinIntRel operator ==(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(int l, const IntVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(int l, const BoolVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(int l, const LinIntExpr& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const IntVar& l, int r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const BoolVar& l, int r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const LinIntExpr& l, int r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const IntVar& l, const IntVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const IntVar& l, const BoolVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const BoolVar& l, const IntVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const BoolVar& l, const BoolVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const IntVar& l, const LinIntExpr& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const BoolVar& l, const LinIntExpr& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const LinIntExpr& l, const IntVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const LinIntExpr& l, const BoolVar& r); /// Construct linear disequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator !=(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(int l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(int l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(int l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const IntVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const BoolVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const LinIntExpr& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const IntVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const IntVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const BoolVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const BoolVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const IntVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const BoolVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const LinIntExpr& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const LinIntExpr& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(int l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(int l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(int l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const IntVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const BoolVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const LinIntExpr& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const IntVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const IntVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const BoolVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const BoolVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const IntVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const BoolVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const LinIntExpr& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const LinIntExpr& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator <=(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(int l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(int l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(int l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const IntVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const BoolVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const LinIntExpr& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const IntVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const IntVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const BoolVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const BoolVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const IntVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const BoolVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const LinIntExpr& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const LinIntExpr& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(int l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(int l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(int l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const IntVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const BoolVar& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const LinIntExpr& l, int r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const IntVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const IntVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const BoolVar& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const BoolVar& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const IntVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const BoolVar& l, const LinIntExpr& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const LinIntExpr& l, const IntVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const LinIntExpr& l, const BoolVar& r); /// Construct linear inequality relation GECODE_MINIMODEL_EXPORT LinIntRel operator >=(const LinIntExpr& l, const LinIntExpr& r); //@}
#ifdef GECODE_HAS_FLOAT_VARS
/// Base class for non-linear float expressions class NonLinFloatExpr { public: /// Return variable constrained to be equal to the expression virtual FloatVar post(Home home, FloatVar* ret) const = 0; /// Post expression to be in relation \a frt with \a c virtual void post(Home home, FloatRelType frt, FloatVal c) const = 0; /// Post reified expression to be in relation \a frt with \a c virtual void post(Home home, FloatRelType frt, FloatVal c, BoolVar b) const = 0; /// Destructor virtual ~NonLinFloatExpr(void); /// Return fresh variable if \a x is null, \a x otherwise static FloatVar result(Home home, FloatVar* x); /// Constrain \a x to be equal to \a y if \a x is not null static FloatVar result(Home home, FloatVar* x, FloatVar y); /// Memory management void* operator new(size_t s); /// Memory management void operator delete(void* p, size_t s); };
}
#include <gecode/minimodel/float-expr.hpp>
namespace Gecode {
/// %Float expressions class LinFloatExpr { friend class LinFloatRel; public: /// Type of linear expression enum NodeType { NT_CONST, ///< Float value constant NT_VAR, ///< Linear term with variable NT_NONLIN, ///< Non-linear expression NT_SUM, ///< Sum of float variables NT_ADD, ///< Addition of linear terms NT_SUB, ///< Subtraction of linear terms NT_MUL ///< Multiplication by coefficient }; private: /// Nodes for linear expressions class Node; Node* n; public: /// Default constructor GECODE_MINIMODEL_EXPORT LinFloatExpr(void); /// Create expression for constant \a c GECODE_MINIMODEL_EXPORT LinFloatExpr(const FloatVal& c); /// Create expression GECODE_MINIMODEL_EXPORT LinFloatExpr(const FloatVar& x); /// Create expression GECODE_MINIMODEL_EXPORT LinFloatExpr(const FloatVar& x, FloatVal a); /// Create sum expression GECODE_MINIMODEL_EXPORT explicit LinFloatExpr(const FloatVarArgs& x); /// Create sum expression GECODE_MINIMODEL_EXPORT LinFloatExpr(const FloatValArgs& a, const FloatVarArgs& x); /// Copy constructor GECODE_MINIMODEL_EXPORT LinFloatExpr(const LinFloatExpr& e); /// Create expression for type and subexpressions GECODE_MINIMODEL_EXPORT LinFloatExpr(const LinFloatExpr& e0, NodeType t, const LinFloatExpr& e1); /// Create expression for type and subexpression GECODE_MINIMODEL_EXPORT LinFloatExpr(const LinFloatExpr& e0, NodeType t, const FloatVal& c); /// Create expression for multiplication GECODE_MINIMODEL_EXPORT LinFloatExpr(FloatVal a, const LinFloatExpr& e); /// Create non-linear expression GECODE_MINIMODEL_EXPORT explicit LinFloatExpr(NonLinFloatExpr* e); /// Assignment operator GECODE_MINIMODEL_EXPORT const LinFloatExpr& operator =(const LinFloatExpr& e); /// Post propagator GECODE_MINIMODEL_EXPORT void post(Home home, FloatRelType frt) const; /// Post reified propagator GECODE_MINIMODEL_EXPORT void post(Home home, FloatRelType frt, const BoolVar& b) const; /// Post propagator and return variable for value GECODE_MINIMODEL_EXPORT FloatVar post(Home home) const; /// Return non-linear expression inside, or null if not non-linear GECODE_MINIMODEL_EXPORT NonLinFloatExpr* nlfe(void) const; /// Destructor GECODE_MINIMODEL_EXPORT ~LinFloatExpr(void); };
class BoolExpr;
/// Linear relations class LinFloatRel { friend class BoolExpr; private: /// Linear float expression describing the entire relation LinFloatExpr e; /// Which relation FloatRelType frt; /// Negate relation type static FloatRelType neg(FloatRelType frt); /// Default constructor LinFloatRel(void); public: /// Create linear float relation for expressions \a l and \a r LinFloatRel(const LinFloatExpr& l, FloatRelType frt, const LinFloatExpr& r); /// Create linear float relation for expression \a l and FloatVal \a r LinFloatRel(const LinFloatExpr& l, FloatRelType frt, FloatVal r); /// Create linear float relation for FloatVal \a l and expression \a r LinFloatRel(FloatVal l, FloatRelType frt, const LinFloatExpr& r); /// Post propagator for relation (if \a t is false for negated relation) void post(Home home, bool t) const; /// Post reified propagator for relation (if \a t is false for negated relation) void post(Home home, const BoolVar& b, bool t) const; };
/** * \defgroup TaskModelMiniModelFloat Linear float expressions and relations * * Linear float expressions can be freely composed of sums and differences of * float variables (Gecode::FloatVar) with float coefficients and float * constants. * * Linear float relations are obtained from linear float expressions with the normal * relation operators. * * \ingroup TaskModelMiniModel */ //@{ /// Construct linear float expression as sum of float variable and float GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const FloatVal&, const FloatVar&); /// Construct linear float expression as sum of linear float expression and float GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const FloatVal&, const LinFloatExpr&); /// Construct linear float expression as sum of float variable and float GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const FloatVar&, const FloatVal&); /// Construct linear float expression as sum of linear float expression and float GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const LinFloatExpr&, const FloatVal&); /// Construct linear float expression as sum of float variables GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const FloatVar&, const FloatVar&); /// Construct linear float expression as sum of float variable and linear float expression GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const FloatVar&, const LinFloatExpr&); /// Construct linear float expression as sum of linear float expression and float variable GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const LinFloatExpr&, const FloatVar&); /// Construct linear float expression as sum of linear float expressions GECODE_MINIMODEL_EXPORT LinFloatExpr operator +(const LinFloatExpr&, const LinFloatExpr&);
/// Construct linear float expression as sum of float variable and float GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const FloatVal&, const FloatVar&); /// Construct linear float expression as sum of float and linear float expression GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const FloatVal&, const LinFloatExpr&); /// Construct linear float expression as sum of float variable and float GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const FloatVar&, const FloatVal&); /// Construct linear float expression as sum of linear float expression and float GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const LinFloatExpr&, const FloatVal&); /// Construct linear float expression as sum of float variables GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const FloatVar&, const FloatVar&); /// Construct linear float expression as sum of float variable and linear float expression GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const FloatVar&, const LinFloatExpr&); /// Construct linear float expression as sum of linear float expression and float variable GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const LinFloatExpr&, const FloatVar&); /// Construct linear float expression as sum of linear float expressions GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const LinFloatExpr&, const LinFloatExpr&);
/// Construct linear float expression as negative of float variable GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const FloatVar&); /// Construct linear float expression as negative of linear float expression GECODE_MINIMODEL_EXPORT LinFloatExpr operator -(const LinFloatExpr&);
/// Construct linear float expression as product of float coefficient and float variable GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const FloatVal&, const FloatVar&); /// Construct linear float expression as product of float coefficient and float variable GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const FloatVar&, const FloatVal&); /// Construct linear float expression as product of float coefficient and linear float expression GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const LinFloatExpr&, const FloatVal&); /// Construct linear float expression as product of float coefficient and linear float expression GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const FloatVal&, const LinFloatExpr&);
/// Construct linear float expression as sum of float variables GECODE_MINIMODEL_EXPORT LinFloatExpr sum(const FloatVarArgs& x); /// Construct linear float expression as sum of float variables with coefficients GECODE_MINIMODEL_EXPORT LinFloatExpr sum(const FloatValArgs& a, const FloatVarArgs& x);
/// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const FloatVal& l, const FloatVar& r); /// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const FloatVal& l, const LinFloatExpr& r); /// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const FloatVar& l, const FloatVal& r); /// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const LinFloatExpr& l, const FloatVal& r); /// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const FloatVar& l, const FloatVar& r); /// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const FloatVar& l, const LinFloatExpr& r); /// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const LinFloatExpr& l, const FloatVar& r); /// Construct linear float equality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator ==(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const FloatVal& l, const FloatVar& r); /// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const FloatVal& l, const LinFloatExpr& r); /// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const FloatVar& l, const FloatVal& r); /// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const LinFloatExpr& l, const FloatVal& r); /// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const FloatVar& l, const FloatVar& r); /// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const FloatVar& l, const LinFloatExpr& r); /// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const LinFloatExpr& l, const FloatVar& r); /// Construct linear float disequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator !=(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const FloatVal& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const FloatVal& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const FloatVar& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const LinFloatExpr& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const FloatVar& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const FloatVar& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const LinFloatExpr& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const FloatVal& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const FloatVal& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const FloatVar& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const LinFloatExpr& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const FloatVar& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const FloatVar& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const LinFloatExpr& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator <=(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const FloatVal& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const FloatVal& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const FloatVar& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const LinFloatExpr& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const FloatVar& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const FloatVar& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const LinFloatExpr& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const FloatVal& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const FloatVal& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const FloatVar& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const LinFloatExpr& l, const FloatVal& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const FloatVar& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const FloatVar& l, const LinFloatExpr& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const LinFloatExpr& l, const FloatVar& r); /// Construct linear float inequality relation GECODE_MINIMODEL_EXPORT LinFloatRel operator >=(const LinFloatExpr& l, const LinFloatExpr& r); //@}#endif
#ifdef GECODE_HAS_SET_VARS /// %Set expressions class SetExpr { public: /// Type of set expression enum NodeType { NT_VAR, ///< Variable NT_CONST, ///< Constant NT_LEXP, ///< Linear expression NT_CMPL, ///< Complement NT_INTER, ///< Intersection NT_UNION, ///< Union NT_DUNION ///< Disjoint union }; /// %Node for set expression class Node; private: /// Pointer to node for expression Node* n; public: /// Default constructor SetExpr(void); /// Copy constructor GECODE_MINIMODEL_EXPORT SetExpr(const SetExpr& e); /// Construct expression for type and subexpresssions GECODE_MINIMODEL_EXPORT SetExpr(const SetExpr& l, NodeType t, const SetExpr& r); /// Construct expression for variable GECODE_MINIMODEL_EXPORT SetExpr(const SetVar& x); /// Construct expression for integer variable GECODE_MINIMODEL_EXPORT explicit SetExpr(const LinIntExpr& x); /// Construct expression for constant GECODE_MINIMODEL_EXPORT SetExpr(const IntSet& s); /// Construct expression for negation GECODE_MINIMODEL_EXPORT SetExpr(const SetExpr& e, NodeType t); /// Post propagators for expression GECODE_MINIMODEL_EXPORT SetVar post(Home home) const; /// Post propagators for relation GECODE_MINIMODEL_EXPORT void post(Home home, SetRelType srt, const SetExpr& e) const; /// Post propagators for reified relation GECODE_MINIMODEL_EXPORT void post(Home home, BoolVar b, bool t, SetRelType srt, const SetExpr& e) const; /// Assignment operator GECODE_MINIMODEL_EXPORT const SetExpr& operator =(const SetExpr& e); /// Destructor GECODE_MINIMODEL_EXPORT ~SetExpr(void); };
/// Comparison relation (for two-sided comparisons) class SetCmpRel { public: /// Left side of relation SetExpr l; /// Right side of relation SetExpr r; /// Which relation SetRelType srt; /// Constructor SetCmpRel(const SetExpr& l, SetRelType srt, const SetExpr& r); };
/// %Set relations class SetRel { private: /// Expression SetExpr _e0; /// Relation SetRelType _srt; /// Expression SetExpr _e1; public: /// Default constructor SetRel(void); /// Constructor SetRel(const SetExpr& e0, SetRelType srt, const SetExpr& e1); /// Constructor SetRel(const SetCmpRel& r); /// Post propagators for relation (or negated relation if \a t is false) void post(Home home, bool t) const; /// Post propagators for reified relation (or negated relation if \a t is false) void post(Home home, BoolVar b, bool t) const; };
/** * \defgroup TaskModelMiniModelSet Set expressions and relations * * Set expressions and relations can be freely composed of variables * with the usual connectives. * * \ingroup TaskModelMiniModel */
//@{ /// Singleton expression GECODE_MINIMODEL_EXPORT SetExpr singleton(const LinIntExpr&); /// Complement expression GECODE_MINIMODEL_EXPORT SetExpr operator -(const SetExpr&); /// Intersection of set expressions GECODE_MINIMODEL_EXPORT SetExpr operator &(const SetExpr&, const SetExpr&); /// Union of set expressions GECODE_MINIMODEL_EXPORT SetExpr operator |(const SetExpr&, const SetExpr&); /// Disjoint union of set expressions GECODE_MINIMODEL_EXPORT SetExpr operator +(const SetExpr&, const SetExpr&); /// Difference of set expressions GECODE_MINIMODEL_EXPORT SetExpr operator -(const SetExpr&, const SetExpr&);
/// Intersection of set variables GECODE_MINIMODEL_EXPORT SetExpr inter(const SetVarArgs&); /// Union of set variables GECODE_MINIMODEL_EXPORT SetExpr setunion(const SetVarArgs&); /// Disjoint union of set variables GECODE_MINIMODEL_EXPORT SetExpr setdunion(const SetVarArgs&);
/// Cardinality of set expression GECODE_MINIMODEL_EXPORT LinIntExpr cardinality(const SetExpr&); /// Minimum element of set expression GECODE_MINIMODEL_EXPORT LinIntExpr min(const SetExpr&); /// Minimum element of set expression GECODE_MINIMODEL_EXPORT LinIntExpr max(const SetExpr&);
/// Equality of set expressions GECODE_MINIMODEL_EXPORT SetRel operator ==(const SetExpr&, const SetExpr&); /// Disequality of set expressions GECODE_MINIMODEL_EXPORT SetRel operator !=(const SetExpr&, const SetExpr&); /// Subset of set expressions GECODE_MINIMODEL_EXPORT SetCmpRel operator <=(const SetExpr&, const SetExpr&); /// Subset of set expressions GECODE_MINIMODEL_EXPORT BoolExpr operator <=(const SetCmpRel&, const SetExpr&); /// Superset of set expressions GECODE_MINIMODEL_EXPORT SetCmpRel operator >=(const SetExpr&, const SetExpr&); /// Superset of set expressions GECODE_MINIMODEL_EXPORT BoolExpr operator >=(const SetCmpRel&, const SetExpr&); /// Disjointness of set expressions GECODE_MINIMODEL_EXPORT SetRel operator ||(const SetExpr&, const SetExpr&); //@}#endif
/// Boolean expressions class BoolExpr { public: /// Type of Boolean expression enum NodeType { NT_VAR, ///< Variable NT_NOT, ///< Negation NT_AND, ///< Conjunction NT_OR, ///< Disjunction NT_EQV, ///< Equivalence NT_RLIN, ///< Reified linear relation NT_RLINFLOAT, ///< Reified linear relation NT_RSET, ///< Reified set relation NT_MISC ///< Other Boolean expression }; /// Miscealloneous Boolean expressions class GECODE_VTABLE_EXPORT Misc : public HeapAllocated { public: /// Default constructor Misc(void); /** Constrain \a b to be equivalent to the expression * (negated if \a neg) with propagation level * \a ipl. */ virtual void post(Home home, BoolVar b, bool neg, const IntPropLevels& ipls) = 0; /// Destructor virtual GECODE_MINIMODEL_EXPORT ~Misc(void); }; /// %Node for Boolean expression class Node; private: /// Pointer to node for expression Node* n; public: /// Default constructor GECODE_MINIMODEL_EXPORT BoolExpr(void); /// Copy constructor GECODE_MINIMODEL_EXPORT BoolExpr(const BoolExpr& e); /// Construct expression for type and subexpresssions GECODE_MINIMODEL_EXPORT BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r); /// Construct expression for variable GECODE_MINIMODEL_EXPORT BoolExpr(const BoolVar& x); /// Construct expression for negation GECODE_MINIMODEL_EXPORT BoolExpr(const BoolExpr& e, NodeType t); /// Construct expression for reified linear relation GECODE_MINIMODEL_EXPORT BoolExpr(const LinIntRel& rl);#ifdef GECODE_HAS_FLOAT_VARS /// Construct expression for reified float relation GECODE_MINIMODEL_EXPORT BoolExpr(const LinFloatRel& rfl);#endif#ifdef GECODE_HAS_SET_VARS /// Construct expression for reified set relation GECODE_MINIMODEL_EXPORT BoolExpr(const SetRel& rs); /// Construct expression for reified set relation GECODE_MINIMODEL_EXPORT BoolExpr(const SetCmpRel& rs);#endif /// Construct expression for miscellaneous Boolean expression GECODE_MINIMODEL_EXPORT explicit BoolExpr(Misc* m); /// Post propagators for expression GECODE_MINIMODEL_EXPORT BoolVar expr(Home home, const IntPropLevels& ipls) const; /// Post propagators for relation GECODE_MINIMODEL_EXPORT void rel(Home home, const IntPropLevels& ipls) const; /// Assignment operator GECODE_MINIMODEL_EXPORT const BoolExpr& operator =(const BoolExpr& e); /// Destructor GECODE_MINIMODEL_EXPORT ~BoolExpr(void); };
/** * \defgroup TaskModelMiniModelBool Boolean expressions * * Boolean expressions can be freely composed of variables with * the usual connectives and reified linear expressions. * * \ingroup TaskModelMiniModel */
//@{ /// Negated Boolean expression GECODE_MINIMODEL_EXPORT BoolExpr operator !(const BoolExpr&); /// Conjunction of Boolean expressions GECODE_MINIMODEL_EXPORT BoolExpr operator &&(const BoolExpr&, const BoolExpr&); /// Disjunction of Boolean expressions GECODE_MINIMODEL_EXPORT BoolExpr operator ||(const BoolExpr&, const BoolExpr&); /// Exclusive-or of Boolean expressions GECODE_MINIMODEL_EXPORT BoolExpr operator ^(const BoolExpr&, const BoolExpr&);
/// Non-equivalence of Boolean expressions GECODE_MINIMODEL_EXPORT BoolExpr operator !=(const BoolExpr&, const BoolExpr&); /// Equivalence of Boolean expressions GECODE_MINIMODEL_EXPORT BoolExpr operator ==(const BoolExpr&, const BoolExpr&); /// Implication of Boolean expressions GECODE_MINIMODEL_EXPORT BoolExpr operator >>(const BoolExpr&, const BoolExpr&); /// Reverse implication of Boolean expressions GECODE_MINIMODEL_EXPORT BoolExpr operator <<(const BoolExpr&, const BoolExpr&);
//@}
/** * \defgroup TaskModelMiniModelReified Reified expressions * * \ingroup TaskModelMiniModel */
//@{ /// \brief Return expression for \f$ x=n\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const IntVar& x, int n); /// \brief Return expression for \f$ l\leq x \leq m\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const IntVar& x, int l, int m); /// \brief Return expression for \f$ x \in s\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const IntVar& x, const IntSet& s);
#ifdef GECODE_HAS_SET_VARS /// \brief Return expression for \f$ x \sim_{rt} \{i\}\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const SetVar& x, SetRelType rt, int i); /// \brief Return expression for \f$ x \sim_{rt} \{i,\dots,j\}\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const SetVar& x, SetRelType rt, int i, int j); /// \brief Return expression for \f$ x \sim_{rt} s\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const SetVar& x, SetRelType rt, const IntSet& s);#endif
#ifdef GECODE_HAS_FLOAT_VARS /// \brief Return expression for \f$ x=n\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const FloatVar& x, const FloatVal& n); /// \brief Return expression for \f$ l\leq x \leq u\f$ GECODE_MINIMODEL_EXPORT BoolExpr dom(const FloatVar& x, FloatNum l, FloatNum u);#endif //@}
/** * \defgroup TaskModelMiniModelMixed Mixed integer and set expressions * * \ingroup TaskModelMiniModel */
//@{#ifdef GECODE_HAS_SET_VARS /// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ i=x\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator ==(const SetExpr& s, const LinIntExpr& x); /// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ x=i\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator ==(const LinIntExpr& x, const SetExpr& s); /// Prevent comparison with IntSet BoolExpr operator ==(const LinIntExpr&, IntSet) = delete; /// Prevent comparison with IntSet BoolExpr operator ==(IntSet, const LinIntExpr&) = delete;
/// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ i\neq x\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator !=(const SetExpr& s, const LinIntExpr& x); /// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ x\neq i\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator !=(const LinIntExpr& x, const SetExpr& s); /// Prevent comparison with IntSet BoolExpr operator !=(const LinIntExpr&, IntSet) = delete; /// Prevent comparison with IntSet BoolExpr operator !=(IntSet, const LinIntExpr&) = delete;
/// \brief Return expression for \f$|s|\geq 6 \land \forall i\in s:\ i\leq x\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator <=(const SetExpr& s, const LinIntExpr& x); /// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ x\leq i\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator <=(const LinIntExpr& x, const SetExpr& s); /// Prevent comparison with IntSet BoolExpr operator <=(const LinIntExpr&, IntSet) = delete; /// Prevent comparison with IntSet BoolExpr operator <=(IntSet, const LinIntExpr&) = delete;
/// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ i<x\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator <(const SetExpr& s, const LinIntExpr& x); /// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ x<i\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator <(const LinIntExpr& x, const SetExpr& s); /// Prevent comparison with IntSet BoolExpr operator <(const LinIntExpr&, IntSet) = delete; /// Prevent comparison with IntSet BoolExpr operator <(IntSet, const LinIntExpr&) = delete;
/// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ i\geq x\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator >=(const SetExpr& s, const LinIntExpr& x); /// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ x\geq i\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator >=(const LinIntExpr& x, const SetExpr& s); /// Prevent comparison with IntSet BoolExpr operator >=(const LinIntExpr&, IntSet) = delete; /// Prevent comparison with IntSet BoolExpr operator >=(IntSet, const LinIntExpr&) = delete;
/// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ i>x\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator >(const SetExpr& s, const LinIntExpr& x); /// \brief Return expression for \f$|s|\geq 1 \land \forall i\in s:\ x>i\f$ GECODE_MINIMODEL_EXPORT BoolExpr operator >(const LinIntExpr& x, const SetExpr& s); /// Prevent comparison with IntSet BoolExpr operator >(const LinIntExpr&, IntSet) = delete; /// Prevent comparison with IntSet BoolExpr operator >(IntSet, const LinIntExpr&) = delete;#endif //@}
/** * \defgroup TaskModelMiniModelPost Posting of expressions and relations * * \ingroup TaskModelMiniModel */ //@{ /// Post linear expression and return its value GECODE_MINIMODEL_EXPORT IntVar expr(Home home, const LinIntExpr& e, const IntPropLevels& ipls=IntPropLevels::def);#ifdef GECODE_HAS_FLOAT_VARS /// Post float expression and return its value GECODE_MINIMODEL_EXPORT FloatVar expr(Home home, const LinFloatExpr& e);#endif#ifdef GECODE_HAS_SET_VARS /// Post set expression and return its value GECODE_MINIMODEL_EXPORT SetVar expr(Home home, const SetExpr& e);#endif /// Post Boolean expression and return its value GECODE_MINIMODEL_EXPORT BoolVar expr(Home home, const BoolExpr& e, const IntPropLevels& ipls=IntPropLevels::def); /// Post Boolean relation GECODE_MINIMODEL_EXPORT void rel(Home home, const BoolExpr& e, const IntPropLevels& ipls=IntPropLevels::def); //@}
}
#include <gecode/minimodel/int-rel.hpp>#include <gecode/minimodel/float-rel.hpp>#include <gecode/minimodel/bool-expr.hpp>#include <gecode/minimodel/set-expr.hpp>#include <gecode/minimodel/set-rel.hpp>
namespace Gecode {
namespace MiniModel { class ExpInfo; }
/** * \brief Regular expressions over integer values * * \ingroup TaskModelMiniModel */ class GECODE_MINIMODEL_EXPORT REG { friend class MiniModel::ExpInfo; private: /// Implementation of the actual expression tree class Exp; /// The expression tree Exp* e; /// Initialize with given expression tree \a REG(Exp* e); /// Return string representatinon of expression tree std::string toString(void) const; public: /// Initialize as empty sequence (epsilon) REG(void); /// Initialize as single integer \a s REG(int s); /** * \brief Initialize as alternative of integers * * Throws an exception of type MiniModel::TooFewArguments if \a x * is empty. */ REG(const IntArgs& x);
/// Initialize from regular expression \a r REG(const REG& r); /// Assign to regular expression \a r const REG& operator =(const REG& r);
/// Return expression for: this expression followed by \a r REG operator +(const REG& r); /// This expression is followed by \a r REG& operator +=(const REG& r); /// Return expression for: this expression or \a r REG operator |(const REG& r); /// This expression or \a r REG& operator |=(const REG& r); /// Return expression for: this expression arbitrarily often (Kleene star) REG operator *(void); /// Return expression for: this expression at least once REG operator +(void); /// Return expression for: this expression at least \a n and at most \a m times REG operator ()(unsigned int n, unsigned int m); /// Return expression for: this expression at least \a n times REG operator ()(unsigned int n); /// Print expression template<class Char, class Traits> std::basic_ostream<Char,Traits>& print(std::basic_ostream<Char,Traits>& os) const; /// Return DFA for regular expression operator DFA(void); /// Destructor ~REG(void); };
/** \relates Gecode::REG * Print regular expression \a r */ template<class Char, class Traits> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
}
#include <gecode/minimodel/reg.hpp>
namespace Gecode {
/** * \defgroup TaskModelMiniModelArith Arithmetic functions * * \ingroup TaskModelMiniModel */ //@{ /// \brief Return expression for \f$x\cdot y\f$ GECODE_MINIMODEL_EXPORT LinIntExpr operator *(const LinIntExpr& x, const LinIntExpr& y); /// \brief Return expression for \f$x\ \mathrm{div}\ y\f$ GECODE_MINIMODEL_EXPORT LinIntExpr operator /(const LinIntExpr& x, const LinIntExpr& y); /// \brief Return expression for \f$x\ \mathrm{mod}\ y\f$ GECODE_MINIMODEL_EXPORT LinIntExpr operator %(const LinIntExpr& x, const LinIntExpr& y); /// \brief Return expression for \f$|e|\f$ GECODE_MINIMODEL_EXPORT LinIntExpr abs(const LinIntExpr& e); /// \brief Return expression for \f$\min(x,y)\f$ GECODE_MINIMODEL_EXPORT LinIntExpr min(const LinIntExpr& x, const LinIntExpr& y); /// \brief Return expression for \f$\min(x)\f$ GECODE_MINIMODEL_EXPORT LinIntExpr min(const IntVarArgs& x); /// \brief Return expression for \f$\max(x,y)\f$ GECODE_MINIMODEL_EXPORT LinIntExpr max(const LinIntExpr& x, const LinIntExpr& y); /// \brief Return expression for \f$\max(x)\f$ GECODE_MINIMODEL_EXPORT LinIntExpr max(const IntVarArgs& x); /// \brief Return expression for \f$x^2\f$ GECODE_MINIMODEL_EXPORT LinIntExpr sqr(const LinIntExpr& x); /// \brief Return expression for \f$\lfloor\sqrt{x}\rfloor\f$ GECODE_MINIMODEL_EXPORT LinIntExpr sqrt(const LinIntExpr& x); /// \brief Return expression for \f$x^n\f$ GECODE_MINIMODEL_EXPORT LinIntExpr pow(const LinIntExpr& x, int n); /// \brief Return expression for \f$\lfloor\sqrt[n]{x}\rfloor\f$ GECODE_MINIMODEL_EXPORT LinIntExpr nroot(const LinIntExpr& x, int n); /// \brief Return expression for \f$x[y]\f$ GECODE_MINIMODEL_EXPORT LinIntExpr element(const IntVarArgs& x, const LinIntExpr& y); /// \brief Return expression for \f$x[y]\f$ GECODE_MINIMODEL_EXPORT BoolExpr element(const BoolVarArgs& x, const LinIntExpr& y); /// \brief Return expression for \f$x[y]\f$ GECODE_MINIMODEL_EXPORT LinIntExpr element(const IntArgs& x, const LinIntExpr& y); /// \brief Return expression for if-then-else \f$b?x:y\f$ GECODE_MINIMODEL_EXPORT LinIntExpr ite(const BoolExpr& b, const LinIntExpr& x, const LinIntExpr& y); //@}
#ifdef GECODE_HAS_FLOAT_VARS /// \brief Return expression as product of float variables GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const FloatVar&, const FloatVar&); /// \brief Return expression as product of float variable and linear float expression GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const FloatVar&, const LinFloatExpr&); /// \brief Return expression as product of linear float expression and float variable GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const LinFloatExpr&, const FloatVar&); /// \brief Return expression for \f$|e|\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr abs(const LinFloatExpr& e); /// \brief Return expression for \f$\min(x,y)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr min(const LinFloatExpr& x, const LinFloatExpr& y); /// \brief Return expression for \f$\min(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr min(const FloatVarArgs& x); /// \brief Return expression for \f$\max(x,y)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr max(const LinFloatExpr& x, const LinFloatExpr& y); /// \brief Return expression for \f$\max(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr max(const FloatVarArgs& x); /// \brief Return expression for \f$x\cdot y\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr operator *(const LinFloatExpr& x, const LinFloatExpr& y); /// \brief Return expression for \f$x/y\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr operator /(const LinFloatExpr& x, const LinFloatExpr& y); /// \brief Return expression for \f$x^2\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr sqr(const LinFloatExpr& x); /// \brief Return expression for \f$\sqrt{x}\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr sqrt(const LinFloatExpr& x); /// \brief Return expression for \f$x^n\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr pow(const LinFloatExpr& x, int n); /// \brief Return expression for \f$x^{1/n}\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr nroot(const LinFloatExpr& x, int n); //@}
#ifdef GECODE_HAS_MPFR /** * \defgroup TaskModelMiniModelTrans Transcendental functions * * \ingroup TaskModelMiniModel */ //@{ /// \brief Return expression for \f$ \mathrm{exp}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr exp(const LinFloatExpr& x); /// \brief Return expression for \f$ \mathrm{log}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr log(const LinFloatExpr& x); //@}
/** * \defgroup TaskModelMiniModelTrigo Trigonometric functions * * \ingroup TaskModelMiniModel */ //@{ /// \brief Return expression for \f$ \mathrm{asin}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr asin(const LinFloatExpr& x); /// \brief Return expression for \f$ \mathrm{sin}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr sin(const LinFloatExpr& x); /// \brief Return expression for \f$ \mathrm{acos}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr acos(const LinFloatExpr& x); /// \brief Return expression for \f$ \mathrm{cos}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr cos(const LinFloatExpr& x); /// \brief Return expression for \f$ \mathrm{atan}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr atan(const LinFloatExpr& x); /// \brief Return expression for \f$ \mathrm{tan}(x)\f$ GECODE_MINIMODEL_EXPORT LinFloatExpr tan(const LinFloatExpr& x); //@}#endif#endif
}
namespace Gecode {
/** * \defgroup TaskModelMiniModelChannel Channel functions * * \ingroup TaskModelMiniModel */ //@{ /// Return Boolean variable equal to \f$x\f$ BoolVar channel(Home home, IntVar x, IntPropLevel ipl=IPL_DEF); /// Return integer variable equal to \f$b\f$ IntVar channel(Home home, BoolVar b, IntPropLevel ipl=IPL_DEF);#ifdef GECODE_HAS_FLOAT_VARS /// Return integer variable equal to \f$f\f$ IntVar channel(Home home, FloatVar f);#endif#ifdef GECODE_HAS_SET_VARS /// Return set variable equal to \f$\{x_0,\dots,x_{n-1}\}\f$ SetVar channel(Home home, const IntVarArgs& x, IntPropLevel ipl=IPL_DEF);#endif //@}
}
#include <gecode/minimodel/channel.hpp>
namespace Gecode {
/** * \defgroup TaskModelMiniModelIntAlias Aliases for integer constraints * * Contains definitions of common constraints which have different * names in Gecode. * * \ingroup TaskModelMiniModel */
//@{ /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\leq m\f$ * * Supports domain consistent propagation only. */ void atmost(Home home, const IntVarArgs& x, int n, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\leq m\f$ * * Supports domain consistent propagation only. */ void atmost(Home home, const IntVarArgs& x, IntVar y, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\leq m\f$ * * Supports domain consistent propagation only. * * Throws an exception of type Int::ArgumentSizeMismatch, if * \a x and \a y are of different size. */ void atmost(Home home, const IntVarArgs& x, const IntArgs& y, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\leq z\f$ * * Supports domain consistent propagation only. */ void atmost(Home home, const IntVarArgs& x, int n, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\leq z\f$ * * Supports domain consistent propagation only. */ void atmost(Home home, const IntVarArgs& x, IntVar y, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\leq z\f$ * * Supports domain consistent propagation only. * * Throws an exception of type Int::ArgumentSizeMismatch, if * \a x and \a y are of different size. */ void atmost(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z, IntPropLevel ipl=IPL_DEF);
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\geq m\f$ * * Supports domain consistent propagation only. */ void atleast(Home home, const IntVarArgs& x, int n, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\geq m\f$ * * Supports domain consistent propagation only. */ void atleast(Home home, const IntVarArgs& x, IntVar y, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\geq m\f$ * * Supports domain consistent propagation only. * * Throws an exception of type Int::ArgumentSizeMismatch, if * \a x and \a y are of different size. */ void atleast(Home home, const IntVarArgs& x, const IntArgs& y, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\geq z\f$ * * Supports domain consistent propagation only. */ void atleast(Home home, const IntVarArgs& x, int n, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\geq z\f$ * * Supports domain consistent propagation only. */ void atleast(Home home, const IntVarArgs& x, IntVar y, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\geq z\f$ * * Supports domain consistent propagation only. * * Throws an exception of type Int::ArgumentSizeMismatch, if * \a x and \a y are of different size. */ void atleast(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z, IntPropLevel ipl=IPL_DEF);
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}=m\f$ * * Supports domain consistent propagation only. */ void exactly(Home home, const IntVarArgs& x, int n, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}=m\f$ * * Supports domain consistent propagation only. */ void exactly(Home home, const IntVarArgs& x, IntVar y, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}=m\f$ * * Supports domain consistent propagation only. * * Throws an exception of type Int::ArgumentSizeMismatch, if * \a x and \a y are of different size. */ void exactly(Home home, const IntVarArgs& x, const IntArgs& y, int m, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}=z\f$ * * Supports domain consistent propagation only. */ void exactly(Home home, const IntVarArgs& x, int n, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}=z\f$ * * Supports domain consistent propagation only. */ void exactly(Home home, const IntVarArgs& x, IntVar y, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}=z\f$ * * Supports domain consistent propagation only. * * Throws an exception of type Int::ArgumentSizeMismatch, if * \a x and \a y are of different size. */ void exactly(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z, IntPropLevel ipl=IPL_DEF);
/** \brief Post lexical order between \a x and \a y. */ void lex(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y, IntPropLevel ipl=IPL_DEF); /** \brief Post lexical order between \a x and \a y. */ void lex(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y, IntPropLevel ipl=IPL_DEF);
/** \brief Post constraint \f$\{x_0,\dots,x_{n-1}\}=y\f$ */ void values(Home home, const IntVarArgs& x, IntSet y, IntPropLevel ipl=IPL_DEF); //@}
#ifdef GECODE_HAS_SET_VARS /** * \defgroup TaskModelMiniModelSetAlias Aliases for set constraints * * Contains definitions of common constraints which have different * names in Gecode. * * \ingroup TaskModelMiniModel */
//@{ /** \brief Post constraint \f$\{x_0,\dots,x_{n-1}\}=y\f$ * * In addition to constraining \a y to the union of the \a x, this * also posts an nvalue constraint for additional cardinality propagation. */ void channel(Home home, const IntVarArgs& x, SetVar y);
/** \brief Post constraint \f$\bigcup_{i\in y}\{x_i\}=z\f$ */ void range(Home home, const IntVarArgs& x, SetVar y, SetVar z);
/** \brief Post constraint \f$\bigcup_{i\in z}\{j\ |\ x_j=i\}=z\f$ * * Note that this creates one temporary set variable for each element * in the upper bound of \a z, so make sure that the bound is tight. */ void roots(Home home, const IntVarArgs& x, SetVar y, SetVar z); //@}
#endif
}
#include <gecode/minimodel/aliases.hpp>
namespace Gecode {
template<class> class Matrix;
/** \brief A slice of a matrix. * * This class represents a slice of the matrix. It is used to get * context-dependent behaviour. The slice will be automatically * converted to an ArgsType Args-array or to a Matrix<ArgsType> * depending on the context where it is used. */ template<class A> class Slice { public: /// The type of the Args-array type for ValueType values typedef typename ArrayTraits<A>::ArgsType ArgsType; private: ArgsType _r; ///< The elements of the slice int _fc, ///< From column _tc, ///< To column _fr, ///< From row _tr; ///< To row public: /// Construct slice Slice(const Matrix<A>& a, int fc, int tc, int fr, int tr); /** \brief Reverses the contents of the slice, and returns a * reference to it. */ Slice& reverse(void); /// Cast to array type operator ArgsType(void); /// Cast to matrix type operator Matrix<ArgsType>(void);
/// Cast to array type operator const ArgsType(void) const; /// Cast to matrix type operator const Matrix<ArgsType>(void) const; };
/// Concatenate \a x and \a y template<class A> typename Slice<A>::ArgsType operator+(const Slice<A>& x, const Slice<A>& y);
/// Concatenate \a x and \a y template<class A> typename Slice<A>::ArgsType operator+(const Slice<A>& x, const typename ArrayTraits<A>::ArgsType& y);
/// Concatenate \a x and \a y template<class A> typename Slice<A>::ArgsType operator+(const typename ArrayTraits<A>::ArgsType& x, const Slice<A>& y);
/// Concatenate \a x and \a y template<class A> typename Slice<A>::ArgsType operator+(const Slice<A>& x, const typename ArrayTraits<A>::ValueType& y);
/// Concatenate \a x and \a y template<class A> typename Slice<A>::ArgsType operator+(const typename ArrayTraits<A>::ValueType& x, const Slice<A>& y);
/** \brief Matrix-interface for arrays * * This class allows for wrapping some array and accessing it as a * matrix. * * \note This is a light-weight wrapper, and is not intended for * storing variables directly instead of in an array. * * \ingroup TaskModelMiniModel */ template<class A> class Matrix { public: /// The type of elements of this array typedef typename ArrayTraits<A>::ValueType ValueType; /// The type of the Args-array type for ValueType values typedef typename ArrayTraits<A>::ArgsType ArgsType;
private: /// The type of storage for this array typedef typename ArrayTraits<A>::StorageType StorageType; StorageType _a; ///< The array wrapped int _w; ///< The width of the matrix int _h; ///< The height of the matrix
public: /** \brief Basic constructor * * Constructs a Matrix from the array \a a, using \a w and \a h as * the width and height of the matrix. * * The elements in the wrapped array \a a are accessed in * row-major order. * * \exception MiniModel::ArgumentSizeMismatch Raised if the * parameters \a w and \a h doesn't match the size * of the array \a a. */ Matrix(A a, int w, int h);
/** \brief Basic constructor * * Constructs a square Matrix from the array \a a, using \a n as * the length of the sides. * * The elements in the wrapped array \a a are accessed in * row-major order. * * \exception MiniModel::ArgumentSizeMismatch Raised if the * parameter \a n doesn't match the size * of the array \a a. */ Matrix(A a, int n);
/// Return the width of the matrix int width(void) const; /// Return the height of the matrix int height(void) const; /// Return an Args-array of the contents of the matrix ArgsType const get_array(void) const;
/** \brief Access element (\a c, \a r) of the matrix * * \exception MiniModel::ArgumentOutOfRange Raised if \a c or \a r * are out of range. */ ValueType& operator ()(int c, int r);
/** \brief Access element (\a c, \a r) of the matrix * * \exception MiniModel::ArgumentOutOfRange Raised if \a c or \a r * are out of range. */ const ValueType& operator ()(int c, int r) const;
/** \brief Access slice of the matrix * * This function allows accessing a slice of the matrix, located at * columns \f$[fc,tc)\f$ and rows \f$[fr,tr)\f$. The result of this * function is an object that can be converted into either a * Matrix<ArgsType> or into ArgsType. * * For further information, see Slice. */ Slice<A> slice(int fc, int tc, int fr, int tr) const;
/// Access row \a r. Slice<A> row(int r) const;
/// Access column \a c. Slice<A> col(int c) const; };
/** \relates Gecode::Matrix * Print matrix \a m */ template<class Char, class Traits, class A> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const Matrix<A>& m);
/** \relates Gecode::Matrix * Print slice \a s */ template<class Char, class Traits, class A> std::basic_ostream<Char,Traits>& operator <<(std::basic_ostream<Char,Traits>& os, const Slice<A>& s);
/** \brief Element constraint for matrix * * Here, \a x and \a y are the coordinates and \a z is the value * at position \a m(x,y). * \relates Gecode::Matrix */ void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Element constraint for matrix * * Here, \a x and \a y are the coordinates and \a z is the value * at position \a m(x,y). * \relates Gecode::Matrix */ void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y, BoolVar z, IntPropLevel ipl=IPL_DEF); /** \brief Element constraint for matrix * * Here, \a x and \a y are the coordinates and \a z is the value * at position \a m(x,y). * \relates Gecode::Matrix */ void element(Home home, const Matrix<IntVarArgs>& m, IntVar x, IntVar y, IntVar z, IntPropLevel ipl=IPL_DEF); /** \brief Element constraint for matrix * * Here, \a x and \a y are the coordinates and \a z is the value * at position \a m(x,y). * \relates Gecode::Matrix */ void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y, BoolVar z, IntPropLevel ipln=IPL_DEF);#ifdef GECODE_HAS_SET_VARS /** \brief Element constraint for matrix * * Here, \a x and \a y are the coordinates and \a z is the value * at position \a m(x,y). * \relates Gecode::Matrix */ void element(Home home, const Matrix<IntSetArgs>& m, IntVar x, IntVar y, SetVar z); /** \brief Element constraint for matrix * * Here, \a x and \a y are the coordinates and \a z is the value * at position \a m(x,y). * \relates Gecode::Matrix */ void element(Home home, const Matrix<SetVarArgs>& m, IntVar x, IntVar y, SetVar z);#endif
/** \brief Interchangeable rows symmetry specification. * \relates Gecode::Matrix */ template<class A> SymmetryHandle rows_interchange(const Matrix<A>& m); /** \brief Interchangeable columns symmetry specification. * \relates Gecode::Matrix */ template<class A> SymmetryHandle columns_interchange(const Matrix<A>& m); /** \brief Reflect rows symmetry specification. * \relates Gecode::Matrix */ template<class A> SymmetryHandle rows_reflect(const Matrix<A>& m); /** \brief Reflect columns symmetry specification. * \relates Gecode::Matrix */ template<class A> SymmetryHandle columns_reflect(const Matrix<A>& m); /** \brief Reflect around main diagonal symmetry specification. * * The matrix \m must be square. * \relates Gecode::Matrix */ template<class A> SymmetryHandle diagonal_reflect(const Matrix<A>& m);}
#include <gecode/minimodel/matrix.hpp>#include <gecode/minimodel/ldsb.hpp>
/** * \addtogroup TaskModelMiniModelLin * @{ */namespace Gecode {
/// Construct linear expression as sum of \ref IntArgs \ref Slice elements GECODE_MINIMODEL_EXPORT LinIntExpr sum(const Slice<IntArgs>& slice); /// Construct linear expression as sum of \ref IntArgs \ref Matrix elements GECODE_MINIMODEL_EXPORT LinIntExpr sum(const Matrix<IntArgs>& matrix);
}/** @}*/
namespace Gecode {
/** * \defgroup TaskModelMiniModelOptimize Support for cost-based optimization * * Provides for minimizing or maximizing the cost value as defined by * a cost-member function of a space. * * \ingroup TaskModelMiniModel */
/** * \brief Class for minimizing integer cost * \ingroup TaskModelMiniModelOptimize */ class GECODE_VTABLE_EXPORT IntMinimizeSpace : public Space { public: /// Default constructor IntMinimizeSpace(void); /// Constructor for cloning IntMinimizeSpace(IntMinimizeSpace& s); /// Member function constraining according to decreasing cost GECODE_MINIMODEL_EXPORT virtual void constrain(const Space& best); /// Return variable with current cost virtual IntVar cost(void) const = 0; };
/** * \brief Class for maximizing integer cost * \ingroup TaskModelMiniModelOptimize */ class GECODE_VTABLE_EXPORT IntMaximizeSpace : public Space { public: /// Default constructor IntMaximizeSpace(void); /// Constructor for cloning IntMaximizeSpace(IntMaximizeSpace& s); /// Member function constraining according to increasing cost GECODE_MINIMODEL_EXPORT virtual void constrain(const Space& best); /// Return variable with current cost virtual IntVar cost(void) const = 0; };
/** * \brief Class for lexicographically minimizing integer costs * \ingroup TaskModelMiniModelOptimize */ class GECODE_VTABLE_EXPORT IntLexMinimizeSpace : public Space { public: /// Default constructor IntLexMinimizeSpace(void); /// Constructor for cloning IntLexMinimizeSpace(IntLexMinimizeSpace& s); /// Member function constraining according to decreasing costs GECODE_MINIMODEL_EXPORT virtual void constrain(const Space& best); /// Return variables with current costs virtual IntVarArgs cost(void) const = 0; };
/** * \brief Class for lexicographically maximizing integer costs * \ingroup TaskModelMiniModelOptimize */ class GECODE_VTABLE_EXPORT IntLexMaximizeSpace : public Space { public: /// Default constructor IntLexMaximizeSpace(void); /// Constructor for cloning IntLexMaximizeSpace(IntLexMaximizeSpace& s); /// Member function constraining according to increasing costs GECODE_MINIMODEL_EXPORT virtual void constrain(const Space& best); /// Return variables with current costs virtual IntVarArgs cost(void) const = 0; };
#ifdef GECODE_HAS_FLOAT_VARS
/** * \brief Class for minimizing float cost * * The class supports using a step value \a step that will make sure * that better solutions must be better by at least the value of * \a step. * * \ingroup TaskModelMiniModelOptimize */ class GECODE_VTABLE_EXPORT FloatMinimizeSpace : public Space { protected: /// Step by which a next solution has to have lower cost FloatNum step; public: /// Constructor with step \a s FloatMinimizeSpace(FloatNum s=0.0); /// Constructor for cloning FloatMinimizeSpace(FloatMinimizeSpace& s); /// Member function constraining according to cost GECODE_MINIMODEL_EXPORT virtual void constrain(const Space& best); /// Return variable with current cost virtual FloatVar cost(void) const = 0; };
/** * \brief Class for maximizing float cost * * The class supports using a step value \a step that will make sure * that better solutions must be better by at least the value of * \a step. * * \ingroup TaskModelMiniModelOptimize */ class GECODE_VTABLE_EXPORT FloatMaximizeSpace : public Space { protected: /// Step by which a next solution has to have lower cost FloatNum step; public: /// Constructor with step \a s FloatMaximizeSpace(FloatNum s=0.0); /// Constructor for cloning FloatMaximizeSpace(FloatMaximizeSpace& s); /// Member function constraining according to cost GECODE_MINIMODEL_EXPORT virtual void constrain(const Space& best); /// Return variable with current cost virtual FloatVar cost(void) const = 0; };
#endif
}
#include <gecode/minimodel/optimize.hpp>
#endif
// IFDEF: GECODE_HAS_INT_VARS// STATISTICS: minimodel-any