input
stringlengths
10
828
output
stringlengths
5
107
public void augment int x int y this left2right arc x while this may grow flow from source y if logger is loggable level fine logger fine add x y this put ref match x y x this right2left arc y if logger is loggable level fine logger fine rem x y assert this match x y y this left2right arc x assert y 0 if logger is loggable level fine logger fine add x y this put ref match x y this increase matching size y
augment the matching along one alternating path
public void first pass dfs for int i 0 i this nb vertices i this finish date i 0 this seen i false this time 0 for int i 0 i this nb vertices i this first dfsearch i
seen i false color i white in book
public void set plug in constraint plugin hook this hook hook
set the constraint plugin of the constraint
public int read return content current idx
read the next element wihtout incrementing
public void propagate throws contradiction exception system out println propagate this if logger is loggable level finer logger finer propagate this remove useless edges
achieves generalized arc consistency in one call
public int substitute var var oldvar var newvar int nb sub 0 int nb vars this get nb vars for int i 0 i nb vars i var v this get var i if this get var i oldvar this set var i newvar nb sub return nb sub
substitues all occurrences of a variable in a constraint by another variable
protected int domain var impl get card var return additional vars 0
a local short cut accessor
protected int get card var index return additional indices 0
a local short cut accessor
protected void check nb false status throws contradiction exception if nb false status get nb constraints fail else if nb false status get nb constraints 1 nb true status get 0 for int const idx 0 const idx nb constraints const idx if get status const idx null set target status const idx true constraints const idx awake break
this compares the number of false constraints subconstraints whose status is false
public object clone throws clone not supported exception abstract bin composite constraint newc abstract bin composite constraint super clone newc const0 abstract constraint this const0 clone newc const1 abstract constraint this const1 clone return newc
builds a copy of this constraint
public int get sub constraint idx final int var idx if var idx offset return 0 else return 1
returns the index of the sub constraint involving the variable
public int get var idx in opposite final int i int const idx get sub constraint idx i if const idx 0 return const0 get var idx in opposite i else assert const idx 1 return const1 get var idx in opposite i offset offset
returns the variable indx in the opposite constraint
public int get nb vars return const0 get nb vars const1 get nb vars
determines the number of variables that is the sum of all variables
public var get var final int i return i offset const0 get var i const1 get var i offset
accesses the variable i
public void set var final int i final var v if i offset const0 set var i v else const1 set var i offset v
sets the variable i
public boolean is completely instantiated return const0 is completely instantiated const1 is completely instantiated
checks if all variables are instantiated that if sub constraints
public int get constraint idx final int i return i offset const0 get constraint idx i const1 get constraint idx i offset
returns the constraint index according to the variable i
public void set constraint index final int i final int idx if i offset const0 set constraint index i idx else const1 set constraint index i offset idx
sets the constraint index according to the variable i
public constraint get sub constraint final int const idx return const idx 0 const0 const1
accesses the sub constraints
public int get nb sub constraints return 2
returns the number of direct sub constraints 2 here since this is a
public void world pop for int i 0 i trails length i itrail storage trail trails i trail world pop current world
backtracks to the previous choice point in the search tree
public void add long delta set get delta
modifying a stored int by an increment
public stored bit set make bit set int size return new stored bit set this size
factory pattern new stored bit set vector objects are created by the environment
public int cardinality int s 0 for int i 0 i represented by size i s cardinality represented by get i return s
number of bits on
public void set final int bit index this ensure capacity bit index int lidx large index bit index int sidx small index bit index int mask 1 sidx int word represented by get lidx if word mask 0 the bit was not already set represented by set lidx word mask
puts the specified bit on
public void clear final int bit index int lidx large index bit index if lidx represented by size int sidx small index bit index int mask 1 sidx int word represented by get lidx if word mask 0 the bit was already set represented by set lidx word mask
puts the specified bit off
public void add int delta set get delta
modifying a stored int by an increment
public void world push world start levels environment current world 1 current level
moving up to the next world
public void world pop while current level world start levels environment current world current level stored float v variable stack current level v set value stack current level stamp stack current level
moving down to the previous world
private void resize update capacity int new capacity max updates 3 2 first copy the stack of variables stored float tmp1 new stored float new capacity system arraycopy variable stack 0 tmp1 0 variable stack length variable stack tmp1 then copy the stack of former values double tmp2 new double new capacity system arraycopy value stack 0 tmp2 0 value stack length value stack tmp2 then copy the stack of world stamps int tmp3 new int new capacity system arraycopy stamp stack 0 tmp3 0 stamp stack length stamp stack tmp3 last update the capacity max updates new capacity
resizes the data structure to manage more values
public void resize world capacity final int new world capacity int tmp new int new world capacity system arraycopy world start levels 0 tmp 0 world start levels length world start levels tmp max worlds new world capacity
resizes the data structure to manage more values
public void add double delta set get delta
modifying a stored int by an increment
public void launch solver run solver incremental run
commands the solver to start
public int get nb solutions return solver nb solutions
returns the number of solutions encountered during the search
public void clear this event type emptyevent set domain set var modified var get domain get enveloppe domain clear delta domain set domain set var modified var get domain get kernel domain clear delta domain
clears the var delegates to the basic events
public void set node limit int node limit this node limit node limit
sets the node limit i
public boolean can be equal to set var x return false to change body of implemented methods use file settings file templates
check if the both domain intersects
public void set first solution boolean first solution this first solution first solution
sets wether only the first solution must be found
public void set var selector ivar selector var selector this var selector var selector
sets the variable selector the search solver should use
public boolean propagate event throws contradiction exception if logger is loggable level finer logger finer propagate this to string first mark event int evt type event type int evt cause cause freeze if evt type instsetevent propagate inst event evt cause else if evt type boundsevent if evt type envevent propagate enveloppe events evt cause else if evt type kerevent propagate kernel events evt cause else if evt type boundsevent propagate kernel events evt cause propagate enveloppe events evt cause last release event return release
propagates the event through calls to the propagation engine
public void set val iterator ival iterator val iterator this val iterator val iterator
sets the value iterator the search should use
public void propagate inst event int evt cause throws contradiction exception abstract var v get modified var partially stored vector constraints v get constraint vector partially stored int vector indices v get index vector for int iterator cit constraints get index iterator cit has next int idx cit next if idx evt cause set constraint c set constraint constraints get idx if c is active int i indices get idx c awake on inst i
propagates the instantiation event
public void set val selector ival selector val selector this val selector val selector
sets the value selector the search should use
public void propagate kernel events int evt cause throws contradiction exception abstract var v get modified var partially stored vector constraints v get constraint vector partially stored int vector indices v get index vector for int iterator cit constraints get index iterator cit has next int idx cit next if idx evt cause set constraint c set constraint constraints get idx if c is active int i indices get idx c awake onker additions i this get ker event iterator
propagates a set of value removals
public void set restart boolean restart this restart restart
set the optimization strategy
public void propagate enveloppe events int evt cause throws contradiction exception abstract var v get modified var partially stored vector constraints v get constraint vector partially stored int vector indices v get index vector for int iterator cit constraints get index iterator cit has next int idx cit next if idx evt cause set constraint c set constraint constraints get idx if c is active int i indices get idx c awake on env removals i this get env event iterator
propagates a set of value removals
public void set do maximize boolean do maximize this do maximize do maximize
a boolean indicating if the solver minize or maximize the objective function
public void set objective var objective this objective objective
set the variable to optimize
public boolean is encountered limit return solver is encountered limit
checks if a limit has been encountered
public iglobal search limit get encountered limit return solver get encountered limit
if a limit has been encounteres return the involved limit
public void clear delta domain first index being propagated 1 first index to be propagated 1
cleans the data structure implementing the delta domain
public void awake on removals int idx int iterator delta domain throws contradiction exception if delta domain null for delta domain has next int val delta domain next awake on rem idx val else awake on var idx
the default implementation of propagation when a variable has been modified
public int get self index abstract problem pb get problem for int i 0 i pb get nb int constraints i constraint c null c pb get set constraint i todo if c this return i return 1
returns the global index of the constraint among all constraints of the problem
public int get constraint idx int idx if idx 0 return c idx0 else if idx 1 return c idx1 else if idx 2 return c idx2 else return 1
returns the index of the constraint in the specified variable
public boolean is completely instantiated return v0 is instantiated v1 is instantiated v2 is instantiated
checks if all the variables are instantiated
public int get nb vars return 3
returns the number of variables
public var get var int i if i 0 return v0 else if i 1 return v1 else if i 2 return v2 else return null
gets the specified variable
public set var get set var int i if i 0 return v0 else if i 1 return v1 else if i 2 return v2 else return null
gets the code i code th search valued variable
public abstract branching get next branching return next branching
gets the next branching
public void set next branching abstract branching next branching this next branching next branching
sets the next branching
public int size return next size
compute the size of the data structure
public boolean is in cycle final int idx int n next size int k idx 0 n 1 idx 1 return n 0 next get k idx
tests if a given index is in the cycle or not
public int iterator get cycle but iterator final int avoid index int n size if avoid index var event nocause n 1 if n 0 return new cyclic iterator this avoid index else return new empty iterator
builds an iterator to enumerate all indices except one
public int next return 0
the next element
public void run boolean feasible root state true try new tree search problem propagate catch contradiction exception e feasible root state false if feasible root state problem world push main goal explore 1 problem world pop explore is responsible for recordinf problem feasible boolean true in case a solution is found if problem feasible null problem feasible boolean true else if max nb solution stored 0 stop at first sol exists solution restore best solution else problem feasible boolean false end tree search
main entry point searching for one solution
public boolean has next int nextk itnext get k if did circle arnound the end return nextk k nextk 1 nextk end marker else return nextk k nextk end marker
checks if there is more elements
public void incremental run base world problem get environment get world index boolean feasible root state true try new tree search problem propagate catch contradiction exception e feasible root state false if feasible root state problem world push if stop at first sol next solution else while next solution boolean true problem world pop if max nb solution stored 0 stop at first sol exists solution problem world pop until base world restore best solution if is encountered limit exists solution problem feasible boolean false else problem feasible boolean false end tree search
main entry point searching for one solution
public int next int prevk k k itnext get k if did circle arnound the end k prevk prevk 1 useless did circle arnound the end true return k
searchs the next element in the data structure
public void new tree search throws contradiction exception assert problem get solver get search solver this for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i lim reset true nb solutions 0 base world problem get environment get world index
called before a new search tree is explored
public void end tree search if logger is loggable level severe if problem feasible boolean true logger log level info solve new integer nb solutions solutions else logger info solve no solution for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i logger info lim pretty
called before a new search tree is explored
public boolean explore int n abstract problem pb manager problem object v select branching object if v null try return branch on v n catch contradiction exception e return false else if next branching null return int branching next branching explore n else manager record solution manager show solution return manager stop at first sol
a method performing the exploration at the choice point level
public void new tree node throws contradiction exception for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i if lim new node this false encountered limit lim problem get propagation engine raise contradiction lim
called before a node is expanded in the search tree choice point creation
public void new tree search init bounds for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i lim reset true
called when a new search tree is built
public void end tree search for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i lim reset false if problem feasible boolean true sview solve s sol best s s a nb sol if a do maximize a lower bound else a upper bound a limits else if problem feasible boolean false sview solve no sol s a limits else sview solve interrupted before any solution was found s a limits
called when a new search tree has been completely browsed
public void end tree node throws contradiction exception for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i lim end node this
called after a node is expanded in the search tree choice point creation
public void record solution problem feasible boolean true nb solutions nb solutions 1 logger fine solution nb solutions is found if logger is loggable level finer this limits size 0 string buffer sb new string buffer with for int i 0 i limits size i abstract global search limit l abstract global search limit limits get i sb append l pretty sb append logger finer sb to string if logger is loggable level finest logger finest problem solution to string if max nb solution stored 0 super record solution
called when a solution is encountered printing and if needed storing the solution
public int branching get branching return branching
each ivar selector is associated to a branching strategy
public void end tree search for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i lim reset false if logger is loggable level severe if problem feasible boolean true hca bug quand feasible est null logger log level severe solve new integer nb solutions solutions else logger severe solve no solution for int i 0 i limits size i abstract global search limit lim abstract global search limit limits get i logger severe lim pretty pop trace until base world 1 problem world pop until base world 1
called before a new search tree is explored
protected boolean one more loop return lower bound upper bound
loop until the lower bound equals the upper bound
public void print runtime statistics for int i 0 i limits size i logger severe abstract global search limit limits get i pretty
print all statistics
public boolean is encountered limit return encountered limit null
checks if a limit has been encountered
public iglobal search limit get encountered limit return encountered limit
if a limit has been encounteres return the involved limit
public void propagate some events throws contradiction exception while queue size 0 propagation event evt pop event evt propagate event in case the propagation of the event is not complete the event will be pushed right back onto the queue if evt propagate event push event evt
propagates some events in fact all the events of the queue since there
public void propagate one event throws contradiction exception if queue size 0 propagation event evt pop event in case the propagation of the event is not complete the event will be pushed right back onto the queue if evt propagate event push event evt
propagates one single event from the queue usefull for tracing
public propagation event pop event propagation event event propagation event queue pop first last popped event if logger is loggable level finest logger finest just popped event to string return event
pops an event to propagate
public int get cause return cause
returns the cause of this basic var
public boolean is enqueued return event type emptyevent
tests whether the event is currently active present in some queue or not
public var event get event return event
returns the variable event
public constraint get constraint final int i return constraint constraints get i
retrieve the constraint i involving the variable
public int get nb constraints return constraints size
returns the number of constraints involving the variable
public partially stored vector get constraint vector return constraints
access the data structure storing constraints involving a given variable
public void post update inf real var v int idx post event v idx real var event incinf
posts an lower bound event for a real variable
public partially stored int vector get index vector return indices
access the data structure storing indices associated to constraints
public int get var index final int constraint index return indices get constraint index
returns the index of the variable in its constraint i
public void post update sup real var v int idx post event v idx real var event decsup
posts an upper bound event for a real variable
public void erase constraint final constraint c constraints remove c
removes permanently a constraint from the list of constraints
public void post rem env set var v int idx post event v idx set var event remenv
posts a removal event on a set variable
public void post add ker set var v int idx post event v idx set var event addker
posts a kernel addition event on a set variable
public iterator get constraints iterator return new iterator int iterator indices constraints get index iterator public boolean has next return indices has next public object next return constraints get indices next public void remove throw new unsupported operation exception
this methods should be used if one want to access the different constraints
public void flush events for int i 0 i nb const queues i this const event queues i flush event queue this nb pending init const awake event 0 var event queue flush event queue
removes all pending events used when interrupting a propagation because