text
stringlengths
1
22.8M
The Russian Women's Futsal Championship is the women's premier futsal championship in Russia, is operated by the AMFR. It was founded in 1993, which is played under UEFA rules and currently consists of 6 teams. Because of the 2022 Russian invasion of Ukraine, FIFA and Union of European Football Associations (UEFA) suspended from FIFA and UEFA competitions all Russian teams, whether national representative teams or club teams. Champions by year References External links Official Website Futsalplanet Futsal competitions in Russia Russia 1993 establishments in Russia Sports leagues established in 1993 Women's sports leagues in Russia National championships in Russia Professional sports leagues in Russia
Hans Turley (died June 2008) was a literary scholar, known for advancing the role of queer studies within eighteenth-century English literature, especially queer readings of pirate fiction. Turley received his PhD in 1994 from the University of Washington. He taught briefly at Texas Tech University after graduation, then joined the faculty at the University of Connecticut in 1998. Turley is best known for his 1999 monograph Rum, Sodomy, and the Lash: Piracy, Sexuality, and Masculine Identity, which Kathryn R. King describes as "one of the earliest works of eighteenth-century scholarship to introduce queer perspectives into the post-structuralist mix." The book studies homoerotic desire in eighteenth-century works, including Daniel Defoe's novels Robinson Crusoe and Captain Singleton, "opening the hatches" to an interpretation of pirate fiction that does not simply reinforce heteronormativity. The book was also notable for making unusually extensive work of primary sources not usually considered by literary scholars, and for highlighting the semi-fictionalized nature of the sensational pirate "histories" that influenced previous historical work on piracy. Turley was a founding member of the American Society for Eighteenth-Century Studies' Queer Caucus in 1993. From 1997 to 2005, he served as an editor of the journal The Eighteenth Century: Theory and Interpretation, including overseeing a special double issue in 2003 titled "Preposterous Pleasure: Homoeroticism and the Eighteenth Century." Turley died in June 2008. In 2012, a special issue of the journal The Eighteenth Century was published in his memory. References American literary historians Queer theorists American literary critics Gender studies academics 2008 deaths University of Washington alumni University of Connecticut faculty American academics of English literature
```objective-c #import "RNPermissions.h" @interface RNPermissionHandlerStoreKit : NSObject<RNPermissionHandler> @end ```
Pio Iosefo Tuia (born 1943) has been , head of government of Tokelau, six times. The position of ulu rotates annually between the three (one for each of the three atolls), who are elected for terms lasting three years. Tuia served as ulu for the sixth time in February 2011. He was also the faipule of Nukunonu and a member of the Council for the Ongoing Government of Tokelau. It was under Tuia's leadership that Tokelau became, in November 2011, a founding member of the Polynesian Leaders Group, a regional grouping intended to cooperate on a variety of issues including culture and language, education, responses to climate change, and trade and investment. Tuia's five terms: February 1996–February 1997 February 1999–February 2000 February 2002–February 2003 February 2005–February 2006 February 2008–21 February 2009 In the 2006 Queen's Birthday Honours, Tuia was appointed an Officer of the New Zealand Order of Merit, for services to the Tokelau Islands. Notes References Governance of Tokelau 2008 1943 births Living people Heads of Government of Tokelau Members of the Parliament of Tokelau Officers of the New Zealand Order of Merit People from Nukunonu
"Caso Arrumado" is a single by Ana Moura from the album Leva-me aos Fados. It was released on November 23, 2009 in Portugal. Recording and production In 2009, Moura began recording rough demos at World Village studios in Lisbon, Portugal. The demos consisted of Moura's lyrical ideas over various backing tracks. The demos were later rearranged and real instruments were added to replace the samples or keyboards initially emulating them. All string and orchestral arrangements were recorded at World Village studios in Lisbon by Ana Moura and Jorge Fernando. The song was mixed at the studios by Jorge Fernando. Music video In its music video we can see Moura singing in a dark room like in the previous music videos, in the other hand, the room is full of white lights. Official versions Album version - 2:22 Single version - 2:22 References External links Music Video at YouTube 2009 singles Portuguese-language songs 2009 songs
```prolog /* CLP(): Constraint Logic Programming over Integers. Author: Markus Triska E-mail: triska@metalevel.at WWW: path_to_url This library provides CLP(): Constraint Logic Programming over Integers ========================================== Highlights: -) DECLARATIVE implementation of integer arithmetic. -) Fully relational, MONOTONIC execution mode. -) Always TERMINATING labeling. 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. */ :- module(clpz, [ op(760, yfx, #<==>), op(750, xfy, #==>), op(750, yfx, #<==), op(740, yfx, #\/), op(730, yfx, #\), op(720, yfx, #/\), op(710, fy, #\), op(700, xfx, #>), op(700, xfx, #<), op(700, xfx, #>=), op(700, xfx, #=<), op(700, xfx, #=), op(700, xfx, #\=), op(700, xfx, in), op(700, xfx, ins), op(450, xfx, ..), % should bind more tightly than \/ op(150, fx, #), (#>)/2, (#<)/2, (#>=)/2, (#=<)/2, (#=)/2, (#\=)/2, (#\)/1, (#<==>)/2, (#==>)/2, (#<==)/2, (#\/)/2, (#\)/2, (#/\)/2, (in)/2, (ins)/2, all_different/1, all_distinct/1, nvalue/2, sum/3, scalar_product/4, tuples_in/2, labeling/2, label/1, indomain/1, lex_chain/1, serialized/2, global_cardinality/2, global_cardinality/3, circuit/1, cumulative/1, cumulative/2, disjoint2/1, element/3, automaton/3, automaton/8, zcompare/3, chain/2, fd_var/1, fd_inf/2, fd_sup/2, fd_size/2, fd_dom/2, % for use in predicates from library(reif) clpz_t/2, (#=)/3, (#<)/3 % called from goal_expansion % clpz_equal/2, % clpz_geq/2 ]). :- use_module(library(assoc)). :- use_module(library(pairs)). :- use_module(library(between)). :- use_module(library(lists)). :- use_module(library(atts)). :- use_module(library(iso_ext)). :- use_module(library(dcgs)). :- use_module(library(terms)). :- use_module(library(error), [domain_error/3, type_error/3, can_be/2]). :- use_module(library(si)). :- use_module(library(freeze)). :- use_module(library(arithmetic)). :- use_module(library(debug)). :- use_module(library(format)). % :- use_module(library(types)). :- attribute clpz/1, clpz_aux/1, clpz_relation/1, edges/1, flow/1, parent/1, free/1, g0_edges/1, used/1, lowlink/1, value/1, visited/1, index/1, in_stack/1, clpz_gcc_vs/1, clpz_gcc_num/1, clpz_gcc_occurred/1, queue/2, disabled/0. :- dynamic(monotonic/0). :- dynamic(clpz_equal_/2). :- dynamic(clpz_geq_/2). :- dynamic(clpz_neq/2). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compatibility predicates. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ cyclic_term(T) :- \+ acyclic_term(T). must_be(What, Term) :- must_be(What, unknown(Term)-1, Term). must_be(ground, _, Term) :- !, ( ground(Term) -> true ; instantiation_error(Term) ). must_be(acyclic, Where, Term) :- !, ( acyclic_term(Term) -> true ; domain_error(acyclic_term, Term, Where) ). must_be(list, Where, Term) :- !, ( list_si(Term) -> true ; type_error(list, Term, Where) ). must_be(list(What), Where, Term) :- !, must_be(list, Where, Term), maplist(must_be(What, Where), Term). must_be(Type, _, Term) :- error:must_be(Type, Term). instantiation_error(Term) :- instantiation_error(Term, unknown(Term)-1). instantiation_error(_, Goal-Arg) :- throw(error(instantiation_error, instantiation_error(Goal, Arg))). domain_error(Expectation, Term) :- domain_error(Expectation, Term, unknown(Term)-1). type_error(Expectation, Term) :- type_error(Expectation, Term, unknown(Term)-1). :- meta_predicate(partition(1, ?, ?, ?)). partition(Pred, Ls0, As, Bs) :- include(Pred, Ls0, As), exclude(Pred, Ls0, Bs). partition(Pred, Ls0, Ls, Es, Gs) :- partition_(Ls0, Pred, Ls, Es, Gs). partition_([], _, [], [], []). partition_([X|Xs], Pred, Ls0, Es0, Gs0) :- call(Pred, X, Cmp), ( Cmp = (<) -> Ls0 = [X|Rest], partition_(Xs, Pred, Rest, Es0, Gs0) ; Cmp = (=) -> Es0 = [X|Rest], partition_(Xs, Pred, Ls0, Rest, Gs0) ; Cmp = (>) -> Gs0 = [X|Rest], partition_(Xs, Pred, Ls0, Es0, Rest) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - include/3 and exclude/3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- meta_predicate(include(1, ?, ?)). include(_, [], []). include(Goal, [L|Ls0], Ls) :- ( call(Goal, L) -> Ls = [L|Rest] ; Ls = Rest ), include(Goal, Ls0, Rest). :- meta_predicate(exclude(1, ?, ?)). exclude(_, [], []). exclude(Goal, [L|Ls0], Ls) :- ( call(Goal, L) -> Ls = Rest ; Ls = [L|Rest] ), exclude(Goal, Ls0, Rest). %:- discontiguous clpz:goal_expansion/5. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Public operators. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- op(760, yfx, #<==>). :- op(750, xfy, #==>). :- op(750, yfx, #<==). :- op(740, yfx, #\/). :- op(730, yfx, #\). :- op(720, yfx, #/\). :- op(710, fy, #\). :- op(700, xfx, #>). :- op(700, xfx, #<). :- op(700, xfx, #>=). :- op(700, xfx, #=<). :- op(700, xfx, #=). :- op(700, xfx, #\=). :- op(700, xfx, in). :- op(700, xfx, ins). :- op(450, xfx, ..). % should bind more tightly than \/ :- op(150, fx, #). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Privately needed operators. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- op(700, xfx, cis). :- op(700, xfx, cis_geq). :- op(700, xfx, cis_gt). :- op(700, xfx, cis_leq). :- op(700, xfx, cis_lt). :- op(1200, xfx, ++>). /** Constraint Logic Programming over Integers ## Introduction This library provides CLP(): Constraint Logic Programming over Integers. CLP() is an instance of the general CLP(_X_) scheme, extending logic programming with reasoning over specialised domains. CLP() lets us reason about *integers* in a way that honors the relational nature of Prolog. There are two major use cases of CLP() constraints: 1. [*declarative integer arithmetic*](#clpz-integer-arith) 2. solving *combinatorial problems* such as planning, scheduling and allocation tasks. The predicates of this library can be classified as: * _arithmetic_ constraints like `(#=)/2`, `(#>)/2` and `(#\=)/2` * the _membership_ constraints `(in)/2` and `(ins)/2` * the _enumeration_ predicates `indomain/1`, `label/1` and `labeling/2` * _combinatorial_ constraints like `all_distinct/1` and `global_cardinality/2` * _reification_ predicates such as `(#<==>)/2` * _reflection_ predicates such as `fd_dom/2` In most cases, [_arithmetic constraints_](#clpz-arith-constraints) are the only predicates you will ever need from this library. When reasoning over integers, simply replace low-level arithmetic predicates like `(is)/2` and `(>)/2` by the corresponding CLP() constraints like `(#=)/2` and `(#>)/2` to honor and preserve declarative properties of your programs. For satisfactory performance, arithmetic constraints are implicitly rewritten at compilation time so that low-level fallback predicates are automatically used whenever possible. Almost all Prolog programs also reason about integers. Therefore, it is highly advisable that you make CLP() constraints available in all your programs. One way to do this is to put the following directive in your `~/.scryerrc` initialisation file: ``` :- use_module(library(clpz)). ``` All example programs that appear in the CLP() documentation assume that you have done this. Important concepts and principles of this library are illustrated by means of usage examples that are available in a public git repository: [*path_to_url If you are used to the complicated operational considerations that low-level arithmetic primitives necessitate, then moving to CLP() constraints may, due to their power and convenience, at first feel to you excessive and almost like cheating. It _isn't_. Constraints are an integral part of all popular Prolog systems, and they are designed to help you eliminate and avoid the use of low-level and less general primitives by providing declarative alternatives that are meant to be used instead. When teaching Prolog, CLP() constraints should be introduced _before_ explaining low-level arithmetic predicates and their procedural idiosyncrasies. This is because constraints are easy to explain, understand and use due to their purely relational nature. In contrast, the modedness and directionality of low-level arithmetic primitives are impure limitations that are better deferred to more advanced lectures. More information about CLP() constraints and their implementation is contained in: [*metalevel.at/drt.pdf*](path_to_url The best way to discuss applying, improving and extending CLP() constraints is to use the dedicated `clpz` tag on [stackoverflow.com](path_to_url Several of the world's foremost CLP() experts regularly participate in these discussions and will help you for free on this platform. {#clpz-arith-constraints} ## Arithmetic constraints In modern Prolog systems, *arithmetic constraints* subsume and supersede low-level predicates over integers. The main advantage of arithmetic constraints is that they are true _relations_ and can be used in all directions. For most programs, arithmetic constraints are the only predicates you will ever need from this library. The most important arithmetic constraint is `(#=)/2`, which subsumes both `(is)/2` and `(=:=)/2` over integers. Use `(#=)/2` to make your programs more general. In total, the arithmetic constraints are: | Expr1 `#=` Expr2 | Expr1 equals Expr2 | | Expr1 `#\=` Expr2 | Expr1 is not equal to Expr2 | | Expr1 `#>=` Expr2 | Expr1 is greater than or equal to Expr2 | | Expr1 `#=<` Expr2 | Expr1 is less than or equal to Expr2 | | Expr1 `#>` Expr2 | Expr1 is greater than Expr2 | | Expr1 `#<` Expr2 | Expr1 is less than Expr2 | `Expr1` and `Expr2` denote *arithmetic expressions*, which are: | _integer_ | Given value | | _variable_ | Unknown integer | | #(_variable_) | Unknown integer | | -Expr | Unary minus | | Expr + Expr | Addition | | Expr * Expr | Multiplication | | Expr - Expr | Subtraction | | Expr ^ Expr | Exponentiation | | min(Expr,Expr) | Minimum of two expressions | | max(Expr,Expr) | Maximum of two expressions | | Expr `mod` Expr | Modulo induced by floored division | | Expr `rem` Expr | Modulo induced by truncated division | | abs(Expr) | Absolute value | | sign(Expr) | Sign (-1, 0, 1) of Expr | | Expr // Expr | Truncated integer division | | Expr div Expr | Floored integer division | where `Expr` again denotes an arithmetic expression. The bitwise operations `(\)/1`, `(/\)/2`, `(\/)/2`, `(>>)/2`, `(<<)/2`, `lsb/1`, `msb/1`, `popcount/1` and `(xor)/2` are also supported. {#clpz-integer-arith} ## Declarative integer arithmetic The [_arithmetic constraints_](#clpz-arith-constraints) `(#=)/2`, `(#>)/2` etc. are meant to be used _instead_ of the primitives `(is)/2`, `(=:=)/2`, `(>)/2` etc. over integers. Almost all Prolog programs also reason about integers. Therefore, it is recommended that you put the following directive in your `~/.scryerrc` initialisation file to make CLP() constraints available in all your programs: ``` :- use_module(library(clpz)). ``` Throughout the following, it is assumed that you have done this. The most basic use of CLP() constraints is _evaluation_ of arithmetic expressions involving integers. For example: ``` ?- X #= 1+2. X = 3. ``` This could in principle also be achieved with the lower-level predicate `(is)/2`. However, an important advantage of arithmetic constraints is their purely relational nature: Constraints can be used in _all directions_, also if one or more of their arguments are only partially instantiated. For example: ``` ?- 3 #= Y+2. Y = 1. ``` This relational nature makes CLP() constraints easy to explain and use, and well suited for beginners and experienced Prolog programmers alike. In contrast, when using low-level integer arithmetic, we get: ``` ?- 3 is Y+2. error(instantiation_error,(is)/2). ?- 3 =:= Y+2. error(instantiation_error,(is)/2). ``` Due to the necessary operational considerations, the use of these low-level arithmetic predicates is considerably harder to understand and should therefore be deferred to more advanced lectures. For supported expressions, CLP() constraints are drop-in replacements of these low-level arithmetic predicates, often yielding more general programs. See [`n_factorial/2`](#clpz-factorial) for an example. This library uses goal_expansion/2 to automatically rewrite constraints at compilation time so that low-level arithmetic predicates are _automatically_ used whenever possible. For example, the predicate: ``` positive_integer(N) :- N #>= 1. ``` is executed as if it were written as: ``` positive_integer(N) :- ( integer(N) -> N >= 1 ; N #>= 1 ). ``` This illustrates why the performance of CLP() constraints is almost always completely satisfactory when they are used in modes that can be handled by low-level arithmetic. To disable the automatic rewriting, set the Prolog flag `clpz_goal_expansion` to `false`. If you are used to the complicated operational considerations that low-level arithmetic primitives necessitate, then moving to CLP() constraints may, due to their power and convenience, at first feel to you excessive and almost like cheating. It _isn't_. Constraints are an integral part of all popular Prolog systems, and they are designed to help you eliminate and avoid the use of low-level and less general primitives by providing declarative alternatives that are meant to be used instead. {#clpz-factorial} ## Example: Factorial relation We illustrate the benefit of using `(#=)/2` for more generality with a simple example. Consider first a rather conventional definition of `n_factorial/2`, relating each natural number _N_ to its factorial _F_: ``` n_factorial(0, 1). n_factorial(N, F) :- N #> 0, N1 #= N - 1, n_factorial(N1, F1), F #= N * F1. ``` This program uses CLP() constraints _instead_ of low-level arithmetic throughout, and everything that _would have worked_ with low-level arithmetic _also_ works with CLP() constraints, retaining roughly the same performance. For example: ``` ?- n_factorial(47, F). F = 258623241511168180642964355153611979969197632389120000000000 ; false. ``` Now the point: Due to the increased flexibility and generality of CLP() constraints, we are free to _reorder_ the goals as follows: ``` n_factorial(0, 1). n_factorial(N, F) :- N #> 0, N1 #= N - 1, F #= N * F1, n_factorial(N1, F1). ``` In this concrete case, _termination_ properties of the predicate are improved. For example, the following queries now both terminate: ``` ?- n_factorial(N, 1). N = 0 ; N = 1 ; false. ?- n_factorial(N, 3). false. ``` To make the predicate terminate if _any_ argument is instantiated, add the (implied) constraint `F #\= 0` before the recursive call. Otherwise, the query `n_factorial(N, 0)` is the only non-terminating case of this kind. The value of CLP() constraints does _not_ lie in completely freeing us from _all_ procedural phenomena. For example, the two programs do not even have the same _termination properties_ in all cases. Instead, the primary benefit of CLP() constraints is that they allow you to try different execution orders and apply [*declarative debugging*](path_to_url techniques _at all_! Reordering goals (and clauses) can significantly impact the performance of Prolog programs, and you are free to try different variants if you use declarative approaches. Moreover, since all CLP() constraints _always terminate_, placing them earlier can at most _improve_, never worsen, the termination properties of your programs. An additional benefit of CLP() constraints is that they eliminate the complexity of introducing `(is)/2` and `(=:=)/2` to beginners, since _both_ predicates are subsumed by `(#=)/2` when reasoning over integers. {#clpz-combinatorial} ## Combinatorial constraints In addition to subsuming and replacing low-level arithmetic predicates, CLP() constraints are often used to solve combinatorial problems such as planning, scheduling and allocation tasks. Among the most frequently used *combinatorial constraints* are `all_distinct/1`, `global_cardinality/2` and `cumulative/2`. This library also provides several other constraints like `disjoint2/1` and `automaton/8`, which are useful in more specialized applications. {#clpz-domains} ## Domains Each CLP() variable has an associated set of admissible integers, which we call the variable's *domain*. Initially, the domain of each CLP() variable is the set of _all_ integers. CLP() constraints like `(#=)/2`, `(#>)/2` and `(#\=)/2` can at most reduce, and never extend, the domains of their arguments. The constraints `(in)/2` and `(ins)/2` let us explicitly state domains of CLP() variables. The process of determining and adjusting domains of variables is called constraint *propagation*, and it is performed automatically by this library. When the domain of a variable contains only one element, then the variable is automatically unified to that element. Domains are taken into account when further constraints are stated, and by enumeration predicates like labeling/2. {#clpz-sudoku} ## Example: Sudoku As another example, consider _Sudoku_: It is a popular puzzle over integers that can be easily solved with CLP() constraints. ``` sudoku(Rows) :- length(Rows, 9), maplist(same_length(Rows), Rows), append(Rows, Vs), Vs ins 1..9, maplist(all_distinct, Rows), transpose(Rows, Columns), maplist(all_distinct, Columns), Rows = [As,Bs,Cs,Ds,Es,Fs,Gs,Hs,Is], blocks(As, Bs, Cs), blocks(Ds, Es, Fs), blocks(Gs, Hs, Is). blocks([], [], []). blocks([N1,N2,N3|Ns1], [N4,N5,N6|Ns2], [N7,N8,N9|Ns3]) :- all_distinct([N1,N2,N3,N4,N5,N6,N7,N8,N9]), blocks(Ns1, Ns2, Ns3). problem(1, [[_,_,_,_,_,_,_,_,_], [_,_,_,_,_,3,_,8,5], [_,_,1,_,2,_,_,_,_], [_,_,_,5,_,7,_,_,_], [_,_,4,_,_,_,1,_,_], [_,9,_,_,_,_,_,_,_], [5,_,_,_,_,_,_,7,3], [_,_,2,_,1,_,_,_,_], [_,_,_,_,4,_,_,_,9]]). ``` Sample query: ``` ?- problem(1, Rows), sudoku(Rows), maplist(portray_clause, Rows). [9,8,7,6,5,4,3,2,1]. [2,4,6,1,7,3,9,8,5]. [3,5,1,9,2,8,7,4,6]. [1,2,8,5,3,7,6,9,4]. [6,3,4,8,9,2,1,5,7]. [7,9,5,4,6,1,8,3,2]. [5,1,9,2,8,6,4,7,3]. [4,7,2,3,1,9,5,6,8]. [8,6,3,7,4,5,2,1,9]. Rows = [[9,8,7,6,5,4,3,2,1]|...]. ``` In this concrete case, the constraint solver is strong enough to find the unique solution without any search. {#clpz-residual-goals} ## Residual goals Here is an example session with a few queries and their answers: ``` ?- X #> 3. clpz:(X in 4..sup). ?- X #\= 20. clpz:(X in inf..19\/21..sup). ?- 2*X #= 10. X = 5. ?- X*X #= 144. clpz:(X in-12\/12) ; false. ?- 4*X + 2*Y #= 24, X + Y #= 9, [X,Y] ins 0..sup. X = 3, Y = 6. ?- X #= Y #<==> B, X in 0..3, Y in 4..5. B = 0, clpz:(X in 0..3), clpz:(Y in 4..5). ``` The answers emitted by the toplevel are called _residual programs_, and the goals that comprise each answer are called *residual goals*. In each case above, and as for all pure programs, the residual program is declaratively equivalent to the original query. From the residual goals, it is clear that the constraint solver has deduced additional domain restrictions in many cases. To inspect residual goals, it is best to let the toplevel display them for us. Wrap the call of your predicate into `call_residue_vars/2` to make sure that all constrained variables are displayed. To make the constraints a variable is involved in available as a Prolog term for further reasoning within your program, use `copy_term/3`. For example: ``` ?- X #= Y + Z, X in 0..5, copy_term([X,Y,Z], [X,Y,Z], Gs). Gs = [clpz: (X in 0..5), clpz: (Y+Z#=X)], X in 0..5, Y+Z#=X. ``` This library also provides _reflection_ predicates (like `fd_dom/2`, `fd_size/2` etc.) with which we can inspect a variable's current domain. These predicates can be useful if you want to implement your own labeling strategies. {#clpz-search} ## Core relations and search Using CLP() constraints to solve combinatorial tasks typically consists of two phases: 1. First, all relevant constraints are stated. 2. Second, if the domain of each involved variable is _finite_, then _enumeration predicates_ can be used to search for concrete solutions. It is good practice to keep the modeling part, via a dedicated predicate called the *core relation*, separate from the actual search for solutions. This lets us observe termination and determinism properties of the core relation in isolation from the search, and more easily try different search strategies. As an example of a constraint satisfaction problem, consider the cryptoarithmetic puzzle SEND + MORE = MONEY, where different letters denote distinct integers between 0 and 9. It can be modeled in CLP() as follows: ``` puzzle([S,E,N,D] + [M,O,R,E] = [M,O,N,E,Y]) :- Vars = [S,E,N,D,M,O,R,Y], Vars ins 0..9, all_different(Vars), S*1000 + E*100 + N*10 + D + M*1000 + O*100 + R*10 + E #= M*10000 + O*1000 + N*100 + E*10 + Y, M #\= 0, S #\= 0. ``` Notice that we are _not_ using `labeling/2` in this predicate, so that we can first execute and observe the modeling part in isolation. Sample query and its result (actual variables replaced for readability): ``` ?- puzzle(As+Bs=Cs). As = [9, A2, A3, A4], Bs = [1, 0, B3, A2], Cs = [1, 0, A3, A2, C5], A2 in 4..7, all_different([9, A2, A3, A4, 1, 0, B3, C5]), 91*A2+A4+10*B3#=90*A3+C5, A3 in 5..8, A4 in 2..8, B3 in 2..8, C5 in 2..8. ``` From this answer, we see that this core relation _terminates_ and is in fact _deterministic_. Moreover, we see from the residual goals that the constraint solver has deduced more stringent bounds for all variables. Such observations are only possible if modeling and search parts are cleanly separated. Labeling can then be used to search for solutions in a separate predicate or goal: ``` ?- puzzle(As+Bs=Cs), label(As). As = [9,5,6,7], Bs = [1,0,8,5], Cs = [1,0,6,5,2] ; false. ``` In this case, it suffices to label a subset of variables to find the puzzle's unique solution, since the constraint solver is strong enough to reduce the domains of remaining variables to singleton sets. In general though, it is necessary to label all variables to obtain ground solutions. {#clpz-n-queens} ## Example: Eight queens puzzle We illustrate the concepts of the preceding sections by means of the so-called _eight queens puzzle_. The task is to place 8 queens on an 8x8 chessboard such that none of the queens is under attack. This means that no two queens share the same row, column or diagonal. To express this puzzle via CLP() constraints, we must first pick a suitable representation. Since CLP() constraints reason over _integers_, we must find a way to map the positions of queens to integers. Several such mappings are conceivable, and it is not immediately obvious which we should use. On top of that, different constraints can be used to express the desired relations. For such reasons, _modeling_ combinatorial problems via CLP() constraints often necessitates some creativity and has been described as more of an art than a science. In our concrete case, we observe that there must be exactly one queen per column. The following representation therefore suggests itself: We are looking for 8 integers, one for each column, where each integer denotes the _row_ of the queen that is placed in the respective column, and which are subject to certain constraints. In fact, let us now generalize the task to the so-called _N queens puzzle_, which is obtained by replacing 8 by _N_ everywhere it occurs in the above description. We implement the above considerations in the *core relation* `n_queens/2`, where the first argument is the number of queens (which is identical to the number of rows and columns of the generalized chessboard), and the second argument is a list of _N_ integers that represents a solution in the form described above. ``` n_queens(N, Qs) :- length(Qs, N), Qs ins 1..N, safe_queens(Qs). safe_queens([]). safe_queens([Q|Qs]) :- safe_queens(Qs, Q, 1), safe_queens(Qs). safe_queens([], _, _). safe_queens([Q|Qs], Q0, D0) :- Q0 #\= Q, abs(Q0 - Q) #\= D0, D1 #= D0 + 1, safe_queens(Qs, Q0, D1). ``` Note that all these predicates can be used in _all directions_: We can use them to _find_ solutions, _test_ solutions and _complete_ partially instantiated solutions. The original task can be readily solved with the following query: ``` ?- n_queens(8, Qs), label(Qs). Qs = [1,5,8,6,3,7,2,4] ; ... . ``` Using suitable labeling strategies, we can easily find solutions with 80 queens and more: ``` ?- n_queens(80, Qs), labeling([ff], Qs). Qs = [1,3,5,44,42,4,50,7,68,57,76,61,6,39,30,40,8,54,36,41|...] ; ... . ?- time((n_queens(90, Qs), labeling([ff], Qs))). % CPU time: 2.382s Qs = [1,3,5,50,42,4,49,7,59,48,46,63,6,55,47,64,8,70,58,67|...] ; ... . ``` Experimenting with different search strategies is easy because we have separated the core relation from the actual search. {#clpz-optimisation} ## Optimisation We can use `labeling/2` to minimize or maximize the value of a CLP() expression, and generate solutions in increasing or decreasing order of the value. See the labeling options `min(Expr)` and `max(Expr)`, respectively. Again, to easily try different labeling options in connection with optimisation, we recommend to introduce a dedicated predicate for posting constraints, and to use `labeling/2` in a separate goal. This way, we can observe properties of the core relation in isolation, and try different labeling options without recompiling our code. If necessary, we can use `once/1` to commit to the first optimal solution. However, it is often very valuable to see alternative solutions that are _also_ optimal, so that we can choose among optimal solutions by other criteria. For the sake of [*purity*](path_to_url and completeness, we recommend to avoid `once/1` and other constructs that lead to impurities in CLP() programs. Related to optimisation with CLP() constraints are `library(simplex)` and CLP(Q) which reason about _linear_ constraints over rational numbers. {#clpz-reification} ## Reification The constraints `(in)/2`, `(#=)/2`, `(#\=)/2`, `(#<)/2`, `(#>)/2`, `(#=<)/2`, and `(#>=)/2` can be _reified_, which means reflecting their truth values into Boolean values represented by the integers 0 and 1. Let P and Q denote reifiable constraints or Boolean variables, then: | `#\ Q` | True iff Q is false | | `P #\/ Q` | True iff either P or Q | | `P #/\ Q` | True iff both P and Q | | `P #\ Q` | True iff either P or Q, but not both | | `P #<==> Q` | True iff P and Q are equivalent | | `P #==> Q` | True iff P implies Q | | `P #<== Q` | True iff Q implies P | The constraints of this table are reifiable as well. When reasoning over Boolean variables, also consider using CLP(B) constraints as provided by `library(clpb)`. {#clpz-monotonicity} ## Enabling monotonic CLP() In the default execution mode, CLP() constraints still exhibit some non-relational properties. For example, _adding_ constraints can yield new solutions: ``` ?- X #= 2, X = 1+1. false. ?- X = 1+1, X #= 2, X = 1+1. X = 1+1. ``` This behaviour is highly problematic from a logical point of view, and it may render declarative debugging techniques inapplicable. Assert `clpz:monotonic` to make CLP() *monotonic*: This means that _adding_ new constraints _cannot_ yield new solutions. When this flag is `true`, we must wrap variables that occur in arithmetic expressions with the functor `(?)/1` or `(#)/1`. For example: ``` ?- assertz(clpz:monotonic). true. ?- #X #= #Y + #Z. clpz:(#Y+ #Z#= #X). ?- X #= 2, X = 1+1. error(instantiation_error,instantiation_error(unknown(_408),1)). ``` The wrapper can be omitted for variables that are already constrained to integers. {#clpz-custom-constraints} ## Custom constraints We can define custom constraints. The mechanism to do this is not yet finalised, and we welcome suggestions and descriptions of use cases that are important to you. As an example of how it can be done currently, let us define a new custom constraint `oneground(X,Y,Z)`, where Z shall be 1 if at least one of X and Y is instantiated: ``` :- multifile clpz:run_propagator/2. oneground(X, Y, Z) :- clpz:make_propagator(oneground(X, Y, Z), Prop), clpz:init_propagator(X, Prop), clpz:init_propagator(Y, Prop), clpz:trigger_once(Prop). clpz:run_propagator(oneground(X, Y, Z), MState) :- ( integer(X) -> clpz:kill(MState), Z = 1 ; integer(Y) -> clpz:kill(MState), Z = 1 ; true ). ``` First, `clpz:make_propagator/2` is used to transform a user-defined representation of the new constraint to an internal form. With `clpz:init_propagator/2`, this internal form is then attached to X and Y. From now on, the propagator will be invoked whenever the domains of X or Y are changed. Then, `clpz:trigger_once/1` is used to give the propagator its first chance for propagation even though the variables' domains have not yet changed. Finally, `clpz:run_propagator/2` is extended to define the actual propagator. As explained, this predicate is automatically called by the constraint solver. The first argument is the user-defined representation of the constraint as used in `clpz:make_propagator/2`, and the second argument is a mutable state that can be used to prevent further invocations of the propagator when the constraint has become entailed, by using `clpz:kill/1`. An example of using the new constraint: ``` ?- oneground(X, Y, Z), Y = 5. Y = 5, Z = 1, X in inf..sup. ``` @author [Markus Triska](path_to_url */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Duo DCGs ======== A Duo DCG is like a DCG, except that it describes *two* lists at the same time. A Duo DCG rule has the form Head ++> Body. The language construct As+Bs is used within Duo DCGs to describe that the elements in As occur in the first list, and the elements in Bs occur in the second list. Duo DCGs are compiled to Prolog code via term expansion. The interface predicates are: *) duophrase(NT, As, Bs) *) duophrase(NT, As0, As, Bs0, Bs) (difference list version). Duo DCGs could be used to efficiently describe scheduled propagators, taking into account the two possible propagator priorities. However, it turns out that passing around a single argument is more efficient than passing around multiple arguments, and therefore regular DCGs are used for propagator scheduling. Still, everything is completely pure: No global data structures are needed to schedule the propagators! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- meta_predicate(duophrase(4, ?, ?)). :- meta_predicate(duophrase(4, ?, ?, ?, ?)). duophrase(NT, As, Bs) :- duophrase(NT, As, [], Bs, []). duophrase(NT, As0, As, Bs0, Bs) :- call(NT, As0, As, Bs0, Bs). %:- multifile user:term_expansion/6. term_expansion(Term0, Term) :- nonvar(Term0), Term0 = (Head0 ++> Body0), Term = (Head :- Body), duodcg_head(Head0, Head, As0, As, Bs0, Bs), once(duodcg_body(Body0, Body, As0, As, Bs0, Bs)). duodcg_body([], (As0=As,Bs0=Bs), As0, As, Bs0, Bs). duodcg_body(Xs+Ys, (phrase(seq(Xs), As0, As), phrase(seq(Ys), Bs0, Bs)), As0, As, Bs0, Bs). duodcg_body({Goal}, call(Goal), As, As, Bs, Bs). duodcg_body((A0,B0), (A,B), As0, As, Bs0, Bs) :- duodcg_body(A0, A, As0, As1, Bs0, Bs1), duodcg_body(B0, B, As1, As, Bs1, Bs). duodcg_body((A0->B0;C0), (A->B;C), As0, As, Bs0, Bs) :- duodcg_body(A0, A, As0, As1, Bs0, Bs1), duodcg_body(B0, B, As1, As, Bs1, Bs), duodcg_body(C0, C, As0, As, Bs0, Bs). duodcg_body((A->B), Body, As0, As, Bs0, Bs) :- duodcg_body((A->B;false), Body, As0, As, Bs0, Bs). duodcg_body((A0;B0), (A;B), As0, As, Bs0, Bs) :- duodcg_body(A0, A, As0, As, Bs0, Bs), duodcg_body(B0, B, As0, As, Bs0, Bs). duodcg_body(NT0, NT, As0, As, Bs0, Bs) :- duodcg_head(NT0, NT, As0, As, Bs0, Bs). duodcg_head(Head0, Head, As0, As, Bs0, Bs) :- Head0 =.. [F|Args0], append(Args0, [As0,As,Bs0,Bs], Args), Head =.. [F|Args]. goal_expansion(get_attr(Var, Module, Value), (var(Var),get_atts(Var, Access))) :- Access =.. [Module,Value]. goal_expansion(put_attr(Var, Module, Value), put_atts(Var, Access)) :- Access =.. [Module,Value]. goal_expansion(del_attr(Var, Module), (var(Var) -> put_atts(Var, -Access);true)) :- Access =.. [Module,_]. goal_expansion(A cis B, Expansion) :- phrase(cis_goals(B, A), Goals), list_goal(Goals, Expansion). goal_expansion(A cis_lt B, B cis_gt A). goal_expansion(A cis_leq B, B cis_geq A). goal_expansion(A cis_geq B, cis_leq_numeric(B, N)) :- nonvar(A), A = n(N). goal_expansion(A cis_geq B, cis_geq_numeric(A, N)) :- nonvar(B), B = n(N). goal_expansion(A cis_gt B, cis_lt_numeric(B, N)) :- nonvar(A), A = n(N). goal_expansion(A cis_gt B, cis_gt_numeric(A, N)) :- nonvar(B), B = n(N). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A bound is either: n(N): integer N inf: infimum of Z (= negative infinity) sup: supremum of Z (= positive infinity) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ is_bound(n(N)) :- integer(N). is_bound(inf). is_bound(sup). defaulty_to_bound(D, P) :- ( integer(D) -> P = n(D) ; P = D ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compactified is/2 and predicates for several arithmetic expressions with infinities, tailored for the modes needed by this solver. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ % cis_gt only works for terms of depth 0 on both sides cis_gt(sup, B0) :- B0 \== sup. cis_gt(n(N), B) :- cis_lt_numeric(B, N). cis_lt_numeric(inf, _). cis_lt_numeric(n(B), A) :- B < A. cis_gt_numeric(sup, _). cis_gt_numeric(n(B), A) :- B > A. cis_geq(inf, inf). cis_geq(sup, _). cis_geq(n(N), B) :- cis_leq_numeric(B, N). cis_leq_numeric(inf, _). cis_leq_numeric(n(B), A) :- B =< A. cis_geq_numeric(sup, _). cis_geq_numeric(n(B), A) :- B >= A. cis_min(inf, _, inf). cis_min(sup, B, B). cis_min(n(N), B, Min) :- cis_min_(B, N, Min). cis_min_(inf, _, inf). cis_min_(sup, N, n(N)). cis_min_(n(B), A, n(M)) :- M is min(A,B). cis_max(sup, _, sup). cis_max(inf, B, B). cis_max(n(N), B, Max) :- cis_max_(B, N, Max). cis_max_(inf, N, n(N)). cis_max_(sup, _, sup). cis_max_(n(B), A, n(M)) :- M is max(A,B). cis_plus(inf, _, inf). cis_plus(sup, _, sup). cis_plus(n(A), B, Plus) :- cis_plus_(B, A, Plus). cis_plus_(sup, _, sup). cis_plus_(inf, _, inf). cis_plus_(n(B), A, n(S)) :- S is A + B. cis_minus(inf, _, inf). cis_minus(sup, _, sup). cis_minus(n(A), B, M) :- cis_minus_(B, A, M). cis_minus_(inf, _, sup). cis_minus_(sup, _, inf). cis_minus_(n(B), A, n(M)) :- M is A - B. cis_uminus(inf, sup). cis_uminus(sup, inf). cis_uminus(n(A), n(B)) :- B is -A. cis_abs(inf, sup). cis_abs(sup, sup). cis_abs(n(A), n(B)) :- B is abs(A). cis_times(inf, B, P) :- ( B cis_lt n(0) -> P = sup ; B cis_gt n(0) -> P = inf ; P = n(0) ). cis_times(sup, B, P) :- ( B cis_gt n(0) -> P = sup ; B cis_lt n(0) -> P = inf ; P = n(0) ). cis_times(n(N), B, P) :- cis_times_(B, N, P). cis_times_(inf, A, P) :- cis_times(inf, n(A), P). cis_times_(sup, A, P) :- cis_times(sup, n(A), P). cis_times_(n(B), A, n(P)) :- P is A * B. cis_exp(inf, n(Y), R) :- ( even(Y) -> R = sup ; R = inf ). cis_exp(sup, _, sup). cis_exp(n(N), Y, R) :- cis_exp_(Y, N, R). cis_exp_(n(Y), N, n(R)) :- R is N^Y. cis_exp_(sup, _, sup). cis_exp_(inf, _, inf). cis_goals(V, V) --> { var(V) }, !. cis_goals(n(N), n(N)) --> []. cis_goals(inf, inf) --> []. cis_goals(sup, sup) --> []. cis_goals(sign(A0), R) --> cis_goals(A0, A), [cis_sign(A, R)]. cis_goals(abs(A0), R) --> cis_goals(A0, A), [cis_abs(A, R)]. cis_goals(-A0, R) --> cis_goals(A0, A), [cis_uminus(A, R)]. cis_goals(A0+B0, R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_plus(A, B, R)]. cis_goals(A0-B0, R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_minus(A, B, R)]. cis_goals(min(A0,B0), R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_min(A, B, R)]. cis_goals(max(A0,B0), R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_max(A, B, R)]. cis_goals(A0*B0, R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_times(A, B, R)]. cis_goals(div(A0,B0), R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_div(A, B, R)]. cis_goals(A0//B0, R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_slash(A, B, R)]. cis_goals(A0^B0, R) --> cis_goals(A0, A), cis_goals(B0, B), [cis_exp(A, B, R)]. list_goal([], true). list_goal([G|Gs], Goal) :- foldl(list_goal_, Gs, G, Goal). list_goal_(G, G0, (G0,G)). cis_sign(sup, n(1)). cis_sign(inf, n(-1)). cis_sign(n(N), n(S)) :- S is sign(N). cis_div(sup, Y, Z) :- ( Y cis_geq n(0) -> Z = sup ; Z = inf ). cis_div(inf, Y, Z) :- ( Y cis_geq n(0) -> Z = inf ; Z = sup ). cis_div(n(X), Y, Z) :- cis_div_(Y, X, Z). cis_div_(sup, _, n(0)). cis_div_(inf, _, n(0)). cis_div_(n(Y), X, Z) :- ( Y =:= 0 -> ( X >= 0 -> Z = sup ; Z = inf ) ; Z0 is X // Y, Z = n(Z0) ). cis_slash(sup, _, sup). cis_slash(inf, _, inf). cis_slash(n(N), B, S) :- cis_slash_(B, N, S). cis_slash_(sup, _, n(0)). cis_slash_(inf, _, n(0)). cis_slash_(n(B), A, n(S)) :- S is A // B. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A domain is a finite set of disjoint intervals. Internally, domains are represented as trees. Each node is one of: empty: empty domain. split(N, Left, Right) - split on integer N, with Left and Right domains whose elements are all less than and greater than N, respectively. The domain is the union of Left and Right, i.e., N is a hole. from_to(From, To) - interval (From-1, To+1); From and To are bounds Desiderata: rebalance domains; singleton intervals. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Type definition and inspection of domains. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ check_domain(D) :- ( var(D) -> instantiation_error(D) ; is_domain(D) -> true ; domain_error(clpz_domain, D) ). is_domain(empty). is_domain(from_to(From,To)) :- is_bound(From), is_bound(To), From cis_leq To. is_domain(split(S, Left, Right)) :- integer(S), is_domain(Left), is_domain(Right), all_less_than(Left, S), all_greater_than(Right, S). all_less_than(empty, _). all_less_than(from_to(From,To), S) :- From cis_lt n(S), To cis_lt n(S). all_less_than(split(S0,Left,Right), S) :- S0 < S, all_less_than(Left, S), all_less_than(Right, S). all_greater_than(empty, _). all_greater_than(from_to(From,To), S) :- From cis_gt n(S), To cis_gt n(S). all_greater_than(split(S0,Left,Right), S) :- S0 > S, all_greater_than(Left, S), all_greater_than(Right, S). default_domain(from_to(inf,sup)). domain_infimum(from_to(I, _), I). domain_infimum(split(_, Left, _), I) :- domain_infimum(Left, I). domain_supremum(from_to(_, S), S). domain_supremum(split(_, _, Right), S) :- domain_supremum(Right, S). domain_num_elements(empty, n(0)). domain_num_elements(from_to(From,To), Num) :- Num cis To - From + n(1). domain_num_elements(split(_, Left, Right), Num) :- domain_num_elements(Left, NL), domain_num_elements(Right, NR), Num cis NL + NR. domain_direction_element(from_to(n(From), n(To)), Dir, E) :- ( Dir == up -> between(From, To, E) ; between(From, To, E0), E is To - (E0 - From) ). domain_direction_element(split(_, D1, D2), Dir, E) :- ( Dir == up -> ( domain_direction_element(D1, Dir, E) ; domain_direction_element(D2, Dir, E) ) ; ( domain_direction_element(D2, Dir, E) ; domain_direction_element(D1, Dir, E) ) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Test whether domain contains a given integer. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_contains(from_to(From,To), I) :- From cis_leq n(I), n(I) cis_leq To. domain_contains(split(S, Left, Right), I) :- ( I < S -> domain_contains(Left, I) ; I > S -> domain_contains(Right, I) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Test whether a domain contains another domain. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_subdomain(Dom, Sub) :- domain_subdomain(Dom, Dom, Sub). domain_subdomain(from_to(_,_), Dom, Sub) :- domain_subdomain_fromto(Sub, Dom). domain_subdomain(split(_, _, _), Dom, Sub) :- domain_subdomain_split(Sub, Dom, Sub). domain_subdomain_split(empty, _, _). domain_subdomain_split(from_to(From,To), split(S,Left0,Right0), Sub) :- ( To cis_lt n(S) -> domain_subdomain(Left0, Left0, Sub) ; From cis_gt n(S) -> domain_subdomain(Right0, Right0, Sub) ). domain_subdomain_split(split(_,Left,Right), Dom, _) :- domain_subdomain(Dom, Dom, Left), domain_subdomain(Dom, Dom, Right). domain_subdomain_fromto(empty, _). domain_subdomain_fromto(from_to(From,To), from_to(From0,To0)) :- From0 cis_leq From, To0 cis_geq To. domain_subdomain_fromto(split(_,Left,Right), Dom) :- domain_subdomain_fromto(Left, Dom), domain_subdomain_fromto(Right, Dom). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Remove an integer from a domain. The domain is traversed until an interval is reached from which the element can be removed, or until it is clear that no such interval exists. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_remove(empty, _, empty). domain_remove(from_to(L0, U0), X, D) :- domain_remove_(L0, U0, X, D). domain_remove(split(S, Left0, Right0), X, D) :- ( X =:= S -> D = split(S, Left0, Right0) ; X < S -> domain_remove(Left0, X, Left1), ( Left1 == empty -> D = Right0 ; D = split(S, Left1, Right0) ) ; domain_remove(Right0, X, Right1), ( Right1 == empty -> D = Left0 ; D = split(S, Left0, Right1) ) ). %?- domain_remove(from_to(n(0),n(5)), 3, D). domain_remove_(inf, U0, X, D) :- ( U0 == n(X) -> U1 is X - 1, D = from_to(inf, n(U1)) ; U0 cis_lt n(X) -> D = from_to(inf,U0) ; L1 is X + 1, U1 is X - 1, D = split(X, from_to(inf, n(U1)), from_to(n(L1),U0)) ). domain_remove_(n(N), U0, X, D) :- domain_remove_upper(U0, N, X, D). domain_remove_upper(sup, L0, X, D) :- ( L0 =:= X -> L1 is X + 1, D = from_to(n(L1),sup) ; L0 > X -> D = from_to(n(L0),sup) ; L1 is X + 1, U1 is X - 1, D = split(X, from_to(n(L0),n(U1)), from_to(n(L1),sup)) ). domain_remove_upper(n(U0), L0, X, D) :- ( L0 =:= U0, X =:= L0 -> D = empty ; L0 =:= X -> L1 is X + 1, D = from_to(n(L1), n(U0)) ; U0 =:= X -> U1 is X - 1, D = from_to(n(L0), n(U1)) ; between(L0, U0, X) -> U1 is X - 1, L1 is X + 1, D = split(X, from_to(n(L0), n(U1)), from_to(n(L1), n(U0))) ; D = from_to(n(L0),n(U0)) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Remove all elements greater than / less than a constant. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_remove_greater_than(empty, _, empty). domain_remove_greater_than(from_to(From0,To0), G, D) :- ( From0 cis_gt n(G) -> D = empty ; To cis min(To0,n(G)), D = from_to(From0,To) ). domain_remove_greater_than(split(S,Left0,Right0), G, D) :- ( S =< G -> domain_remove_greater_than(Right0, G, Right), ( Right == empty -> D = Left0 ; D = split(S, Left0, Right) ) ; domain_remove_greater_than(Left0, G, D) ). domain_remove_smaller_than(empty, _, empty). domain_remove_smaller_than(from_to(From0,To0), V, D) :- ( To0 cis_lt n(V) -> D = empty ; From cis max(From0,n(V)), D = from_to(From,To0) ). domain_remove_smaller_than(split(S,Left0,Right0), V, D) :- ( S >= V -> domain_remove_smaller_than(Left0, V, Left), ( Left == empty -> D = Right0 ; D = split(S, Left, Right0) ) ; domain_remove_smaller_than(Right0, V, D) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Remove a whole domain from another domain. (Set difference.) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_subtract(Dom0, Sub, Dom) :- domain_subtract(Dom0, Dom0, Sub, Dom). domain_subtract(empty, _, _, empty). domain_subtract(from_to(From0,To0), Dom, Sub, D) :- ( Sub == empty -> D = Dom ; Sub = from_to(From,To) -> ( From == To -> From = n(X), domain_remove(Dom, X, D) ; From cis_gt To0 -> D = Dom ; To cis_lt From0 -> D = Dom ; From cis_leq From0 -> ( To cis_geq To0 -> D = empty ; From1 cis To + n(1), D = from_to(From1, To0) ) ; To1 cis From - n(1), ( To cis_lt To0 -> From = n(S), From2 cis To + n(1), D = split(S,from_to(From0,To1),from_to(From2,To0)) ; D = from_to(From0,To1) ) ) ; Sub = split(S, Left, Right) -> ( n(S) cis_gt To0 -> domain_subtract(Dom, Dom, Left, D) ; n(S) cis_lt From0 -> domain_subtract(Dom, Dom, Right, D) ; domain_subtract(Dom, Dom, Left, D1), domain_subtract(D1, D1, Right, D) ) ). domain_subtract(split(S, Left0, Right0), _, Sub, D) :- domain_subtract(Left0, Left0, Sub, Left), domain_subtract(Right0, Right0, Sub, Right), ( Left == empty -> D = Right ; Right == empty -> D = Left ; D = split(S, Left, Right) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Complement of a domain - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_complement(D, C) :- default_domain(Default), domain_subtract(Default, D, C). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Convert domain to a list of disjoint intervals From-To. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_intervals(D, Is) :- phrase(domain_intervals(D), Is). domain_intervals(split(_, Left, Right)) --> domain_intervals(Left), domain_intervals(Right). domain_intervals(empty) --> []. domain_intervals(from_to(From,To)) --> [From-To]. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To compute the intersection of two domains D1 and D2, we choose D1 as the reference domain. For each interval of D1, we compute how far and to which values D2 lets us extend it. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domains_intersection(D1, D2, Intersection) :- domains_intersection_(D1, D2, Intersection), Intersection \== empty. domains_intersection_(empty, _, empty). domains_intersection_(from_to(L0,U0), D2, Dom) :- narrow(D2, L0, U0, Dom). domains_intersection_(split(S,Left0,Right0), D2, Dom) :- domains_intersection_(Left0, D2, Left1), domains_intersection_(Right0, D2, Right1), ( Left1 == empty -> Dom = Right1 ; Right1 == empty -> Dom = Left1 ; Dom = split(S, Left1, Right1) ). narrow(empty, _, _, empty). narrow(from_to(L0,U0), From0, To0, Dom) :- From1 cis max(From0,L0), To1 cis min(To0,U0), ( From1 cis_gt To1 -> Dom = empty ; Dom = from_to(From1,To1) ). narrow(split(S, Left0, Right0), From0, To0, Dom) :- ( To0 cis_lt n(S) -> narrow(Left0, From0, To0, Dom) ; From0 cis_gt n(S) -> narrow(Right0, From0, To0, Dom) ; narrow(Left0, From0, To0, Left1), narrow(Right0, From0, To0, Right1), ( Left1 == empty -> Dom = Right1 ; Right1 == empty -> Dom = Left1 ; Dom = split(S, Left1, Right1) ) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Union of 2 domains. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domains_union(D1, D2, Union) :- domain_intervals(D1, Is1), domain_intervals(D2, Is2), append(Is1, Is2, IsU0), merge_intervals(IsU0, IsU1), intervals_to_domain(IsU1, Union). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Shift the domain by an offset. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_shift(empty, _, empty). domain_shift(from_to(From0,To0), O, from_to(From,To)) :- From cis From0 + n(O), To cis To0 + n(O). domain_shift(split(S0, Left0, Right0), O, split(S, Left, Right)) :- S is S0 + O, domain_shift(Left0, O, Left), domain_shift(Right0, O, Right). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The new domain contains all values of the old domain, multiplied by a constant multiplier. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_expand(D0, M, D) :- ( M < 0 -> domain_negate(D0, D1), M1 is abs(M), domain_expand_(D1, M1, D) ; M =:= 1 -> D = D0 ; domain_expand_(D0, M, D) ). domain_expand_(empty, _, empty). domain_expand_(from_to(From0, To0), M, from_to(From,To)) :- From cis From0*n(M), To cis To0*n(M). domain_expand_(split(S0, Left0, Right0), M, split(S, Left, Right)) :- S is M*S0, domain_expand_(Left0, M, Left), domain_expand_(Right0, M, Right). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - similar to domain_expand/3, tailored for truncated division: an interval [From,To] is extended to [From*M, ((To+1)*M - 1)], i.e., to all values that truncated integer-divided by M yield a value from interval. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_expand_more(D0, M, D) :- %format("expanding ~w by ~w\n", [D0,M]), ( M < 0 -> domain_negate(D0, D1), M1 is abs(M) ; D1 = D0, M1 = M ), domain_expand_more_(D1, M1, D). %format("yield: ~w\n", [D]). domain_expand_more_(empty, _, empty). domain_expand_more_(from_to(From0, To0), M, from_to(From,To)) :- ( From0 cis_leq n(0) -> From cis (From0-n(1))*n(M) + n(1) ; From cis From0*n(M) ), ( To0 cis_lt n(0) -> To cis To0*n(M) ; To cis (To0+n(1))*n(M) - n(1) ). domain_expand_more_(split(S0, Left0, Right0), M, split(S, Left, Right)) :- S is M*S0, domain_expand_more_(Left0, M, Left), domain_expand_more_(Right0, M, Right). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Scale a domain down by a constant multiplier. Assuming (//)/2. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_contract(D0, M, D) :- %format("contracting ~w by ~w\n", [D0,M]), ( M < 0 -> domain_negate(D0, D1), M1 is abs(M) ; D1 = D0, M1 = M ), domain_contract_(D1, M1, D). domain_contract_(empty, _, empty). domain_contract_(from_to(From0, To0), M, from_to(From,To)) :- ( From0 cis_geq n(0) -> From cis (From0 + n(M) - n(1)) // n(M) ; From cis From0 // n(M) ), ( To0 cis_geq n(0) -> To cis To0 // n(M) ; To cis (To0 - n(M) + n(1)) // n(M) ). domain_contract_(split(_,Left0,Right0), M, D) :- % Scaled down domains do not necessarily retain any holes of % the original domain. domain_contract_(Left0, M, Left), domain_contract_(Right0, M, Right), domains_union(Left, Right, D). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Similar to domain_contract, tailored for division, i.e., {21,23} contracted by 4 is 5. It contracts "less". - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_contract_less(D0, M, D) :- ( M < 0 -> domain_negate(D0, D1), M1 is abs(M) ; D1 = D0, M1 = M ), domain_contract_less_(D1, M1, D). domain_contract_less_(empty, _, empty). domain_contract_less_(from_to(From0, To0), M, from_to(From,To)) :- From cis From0 // n(M), To cis To0 // n(M). domain_contract_less_(split(_,Left0,Right0), M, D) :- % Scaled down domains do not necessarily retain any holes of % the original domain. domain_contract_less_(Left0, M, Left), domain_contract_less_(Right0, M, Right), domains_union(Left, Right, D). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Negate the domain. Left and Right sub-domains and bounds switch sides. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ domain_negate(empty, empty). domain_negate(from_to(From0, To0), from_to(From, To)) :- From cis -To0, To cis -From0. domain_negate(split(S0, Left0, Right0), split(S, Left, Right)) :- S is -S0, domain_negate(Left0, Right), domain_negate(Right0, Left). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Construct a domain from a list of integers. Try to balance it. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ list_to_disjoint_intervals([], []). list_to_disjoint_intervals([N|Ns], Is) :- list_to_disjoint_intervals(Ns, N, N, Is). list_to_disjoint_intervals([], M, N, [n(M)-n(N)]). list_to_disjoint_intervals([B|Bs], M, N, Is) :- ( B =:= N + 1 -> list_to_disjoint_intervals(Bs, M, B, Is) ; Is = [n(M)-n(N)|Rest], list_to_disjoint_intervals(Bs, B, B, Rest) ). list_to_domain(List0, D) :- ( List0 == [] -> D = empty ; sort(List0, List), list_to_disjoint_intervals(List, Is), intervals_to_domain(Is, D) ). intervals_to_domain([], empty) :- !. intervals_to_domain([M-N], from_to(M,N)) :- !. intervals_to_domain(Is, D) :- length(Is, L), FL is L // 2, length(Front, FL), append(Front, Tail, Is), Tail = [n(Start)-_|_], Hole is Start - 1, intervals_to_domain(Front, Left), intervals_to_domain(Tail, Right), D = split(Hole, Left, Right). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% in(?Var, +Domain) % % Var is an element of Domain. Domain is one of: % % * Integer % Singleton set consisting only of _Integer_. % * Lower..Upper % All integers _I_ such that _Lower_ =< _I_ =< _Upper_. % _Lower_ must be an integer or the atom *inf*, which % denotes negative infinity. _Upper_ must be an integer or % the atom *sup*, which denotes positive infinity. % * Domain1 `\/` Domain2 % The union of Domain1 and Domain2. Var in Dom :- clpz_in(Var, Dom). clpz_in(V, D) :- fd_variable(V), drep_to_domain(D, Dom), domain(V, Dom). fd_variable(V) :- can_be(integer, V). %% ins(+Vars, +Domain) % % The variables in the list Vars are elements of Domain. Vs ins D :- fd_must_be_list(Vs), maplist(fd_variable, Vs), drep_to_domain(D, Dom), domains(Vs, Dom). fd_must_be_list(Ls) :- ( fd_var(Ls) -> type_error(list, Ls) ; must_be(list, Ls) ). fd_must_be_list(Ls, Where) :- ( fd_var(Ls) -> type_error(list, Ls, Where) ; must_be(list, Where, Ls) ). %% indomain(?Var) % % Bind Var to all feasible values of its domain on backtracking. The % domain of Var must be finite. indomain(Var) :- label([Var]). order_dom_next(up, Dom, Next) :- domain_infimum(Dom, n(Next)). order_dom_next(down, Dom, Next) :- domain_supremum(Dom, n(Next)). %% label(+Vars) % % Equivalent to labeling([], Vars). label(Vs) :- labeling([], Vs). %% labeling(+Options, +Vars) % % Assign a value to each variable in Vars. Labeling means systematically % trying out values for the finite domain variables Vars until all of % them are ground. The domain of each variable in Vars must be finite. % Options is a list of options that let you exhibit some control over % the search process. Several categories of options exist: % % The variable selection strategy lets you specify which variable of % Vars is labeled next and is one of: % % * leftmost % Label the variables in the order they occur in Vars. This is the % default. % % * ff % _|First fail|_. Label the leftmost variable with smallest domain next, % in order to detect infeasibility early. This is often a good % strategy. % % * ffc % Of the variables with smallest domains, the leftmost one % participating in most constraints is labeled next. % % * min % Label the leftmost variable whose lower bound is the lowest next. % % * max % Label the leftmost variable whose upper bound is the highest next. % % The value order is one of: % % * up % Try the elements of the chosen variable's domain in ascending order. % This is the default. % % * down % Try the domain elements in descending order. % % The branching strategy is one of: % % * step % For each variable X, a choice is made between X = V and X #\= V, % where V is determined by the value ordering options. This is the % default. % % * enum % For each variable X, a choice is made between X = V_1, X = V_2 % etc., for all values V_i of the domain of X. The order is % determined by the value ordering options. % % * bisect % For each variable X, a choice is made between X #=< M and X #> M, % where M is the midpoint of the domain of X. % % At most one option of each category can be specified, and an option % must not occur repeatedly. % % The order of solutions can be influenced with: % % * min(Expr) % * max(Expr) % % This generates solutions in ascending/descending order with respect % to the evaluation of the arithmetic expression Expr. Labeling Vars % must make Expr ground. If several such options are specified, they % are interpreted from left to right, e.g.: % % ``` % ?- [X,Y] ins 10..20, labeling([max(X),min(Y)],[X,Y]). % ``` % % This generates solutions in descending order of X, and for each % binding of X, solutions are generated in ascending order of Y. To % obtain the incomplete behaviour that other systems exhibit with % "maximize(Expr)" and "minimize(Expr)", use once/1, e.g.: % % ``` % once(labeling([max(Expr)], Vars)) % ``` % % Labeling is always complete, always terminates, and yields no % redundant solutions. % labeling(Options, Vars) :- must_be(list, labeling(Options, Vars)-1, Options), fd_must_be_list(Vars, labeling(Options, Vars)-2), maplist(finite_domain(labeling(Options, Vars), 2), Vars), label(Options, Options, default(leftmost), default(up), default(step), [], upto_ground, Vars). finite_domain(Goal, Arg, Var) :- ( fd_get(Var, Dom, _) -> ( domain_infimum(Dom, n(_)), domain_supremum(Dom, n(_)) -> true ; instantiation_error(Dom) ) ; integer(Var) -> true ; must_be(integer, Goal-Arg, Var) ). finite_domain(Var) :- finite_domain(finite_domain(Var), 1, Var). label([O|Os], Options, Selection, Order, Choice, Optim, Consistency, Vars) :- ( var(O)-> instantiation_error(O) ; override(selection, Selection, O, Options, S1) -> label(Os, Options, S1, Order, Choice, Optim, Consistency, Vars) ; override(order, Order, O, Options, O1) -> label(Os, Options, Selection, O1, Choice, Optim, Consistency, Vars) ; override(choice, Choice, O, Options, C1) -> label(Os, Options, Selection, Order, C1, Optim, Consistency, Vars) ; optimisation(O) -> label(Os, Options, Selection, Order, Choice, [O|Optim], Consistency, Vars) ; consistency(O, O1) -> label(Os, Options, Selection, Order, Choice, Optim, O1, Vars) ; domain_error(labeling_option, O) ). label([], _, Selection, Order, Choice, Optim0, Consistency, Vars) :- maplist(arg(1), [Selection,Order,Choice], [S,O,C]), ( Optim0 == [] -> label(Vars, S, O, C, Consistency) ; reverse(Optim0, Optim), exprs_singlevars(Optim, SVs), call_cleanup(optimise(Vars, [S,O,C], SVs), retractall(extremum(_))) ). % Introduce new variables for each min/max expression to avoid % reparsing expressions during optimisation. exprs_singlevars([], []). exprs_singlevars([E|Es], [SV|SVs]) :- E =.. [F,Expr], #Single #= Expr, SV =.. [F,Single], exprs_singlevars(Es, SVs). all_dead(fd_props(Bs,Gs,Os)) :- all_dead_(Bs), all_dead_(Gs), all_dead_(Os). all_dead_([]). all_dead_([propagator(_, S)|Ps]) :- S == dead, all_dead_(Ps). label([], _, _, _, Consistency) :- !, ( Consistency = upto_in(I0,I) -> I0 = I ; true ). label(Vars, Selection, Order, Choice, Consistency) :- ( Vars = [V|Vs], nonvar(V) -> label(Vs, Selection, Order, Choice, Consistency) ; select_var(Selection, Vars, Var, RVars), ( var(Var) -> ( Consistency = upto_in(I0,I), fd_get(Var, _, Ps), all_dead(Ps) -> fd_size(Var, Size), I1 is I0*Size, label(RVars, Selection, Order, Choice, upto_in(I1,I)) ; Consistency = upto_in, fd_get(Var, _, Ps), all_dead(Ps) -> label(RVars, Selection, Order, Choice, Consistency) ; choice_order_variable(Choice, Order, Var, RVars, Vars, Selection, Consistency) ) ; label(RVars, Selection, Order, Choice, Consistency) ) ). choice_order_variable(step, Order, Var, Vars, Vars0, Selection, Consistency) :- fd_get(Var, Dom, _), order_dom_next(Order, Dom, Next), ( Var = Next, label(Vars, Selection, Order, step, Consistency) ; neq_num(Var, Next), label(Vars0, Selection, Order, step, Consistency) ). choice_order_variable(enum, Order, Var, Vars, _, Selection, Consistency) :- fd_get(Var, Dom0, _), domain_direction_element(Dom0, Order, Var), label(Vars, Selection, Order, enum, Consistency). choice_order_variable(bisect, Order, Var, _, Vars0, Selection, Consistency) :- fd_get(Var, Dom, _), domain_infimum(Dom, n(I)), domain_supremum(Dom, n(S)), Mid0 is (I + S) // 2, ( Mid0 =:= S -> Mid is Mid0 - 1 ; Mid = Mid0 ), ( Order == up -> ( Var #=< Mid ; Var #> Mid ) ; Order == down -> ( Var #> Mid ; Var #=< Mid ) ; domain_error(bisect_up_or_down, Order) ), label(Vars0, Selection, Order, bisect, Consistency). override(What, Prev, Value, Options, Result) :- call(What, Value), override_(Prev, Value, Options, Result). override_(default(_), Value, _, user(Value)). override_(user(Prev), Value, Options, _) :- ( Value == Prev -> domain_error(nonrepeating_labeling_options, Options) ; domain_error(consistent_labeling_options, Options) ). selection(ff). selection(ffc). selection(min). selection(max). selection(leftmost). choice(step). choice(enum). choice(bisect). order(up). order(down). consistency(upto_in(I), upto_in(1, I)). consistency(upto_in, upto_in). consistency(upto_ground, upto_ground). optimisation(min(_)). optimisation(max(_)). select_var(leftmost, [Var|Vars], Var, Vars). select_var(min, [V|Vs], Var, RVars) :- find_min(Vs, V, Var), delete_eq([V|Vs], Var, RVars). select_var(max, [V|Vs], Var, RVars) :- find_max(Vs, V, Var), delete_eq([V|Vs], Var, RVars). select_var(ff, [V|Vs], Var, RVars) :- fd_size_(V, n(S)), find_ff(Vs, V, S, Var), delete_eq([V|Vs], Var, RVars). select_var(ffc, [V|Vs], Var, RVars) :- find_ffc(Vs, V, Var), delete_eq([V|Vs], Var, RVars). find_min([], Var, Var). find_min([V|Vs], CM, Min) :- ( min_lt(V, CM) -> find_min(Vs, V, Min) ; find_min(Vs, CM, Min) ). find_max([], Var, Var). find_max([V|Vs], CM, Max) :- ( max_gt(V, CM) -> find_max(Vs, V, Max) ; find_max(Vs, CM, Max) ). find_ff([], Var, _, Var). find_ff([V|Vs], CM, S0, FF) :- ( nonvar(V) -> find_ff(Vs, CM, S0, FF) ; ( fd_size_(V, n(S1)), S1 < S0 -> find_ff(Vs, V, S1, FF) ; find_ff(Vs, CM, S0, FF) ) ). find_ffc([], Var, Var). find_ffc([V|Vs], Prev, FFC) :- ( ffc_lt(V, Prev) -> find_ffc(Vs, V, FFC) ; find_ffc(Vs, Prev, FFC) ). ffc_lt(X, Y) :- ( fd_get(X, XD, XPs) -> domain_num_elements(XD, n(NXD)) ; NXD = 1, XPs = [] ), ( fd_get(Y, YD, YPs) -> domain_num_elements(YD, n(NYD)) ; NYD = 1, YPs = [] ), ( NXD < NYD -> true ; NXD =:= NYD, props_number(XPs, NXPs), props_number(YPs, NYPs), NXPs > NYPs ). min_lt(X,Y) :- bounds(X,LX,_), bounds(Y,LY,_), LX < LY. max_gt(X,Y) :- bounds(X,_,UX), bounds(Y,_,UY), UX > UY. bounds(X, L, U) :- ( fd_get(X, Dom, _) -> domain_infimum(Dom, n(L)), domain_supremum(Dom, n(U)) ; L = X, U = L ). delete_eq([], _, []). delete_eq([X|Xs], Y, List) :- ( nonvar(X) -> delete_eq(Xs, Y, List) ; X == Y -> List = Xs ; List = [X|Tail], delete_eq(Xs, Y, Tail) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - contracting/1 -- subject to change This can remove additional domain elements from the boundaries. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ contracting(Vs) :- must_be(list, contracting(Vs)-1, Vs), maplist(finite_domain(contracting(Vs), 1), Vs), contracting(Vs, false, Vs). contracting([], Repeat, Vars) :- ( Repeat -> contracting(Vars, false, Vars) ; true ). contracting([V|Vs], Repeat, Vars) :- fd_inf(V, Min), ( \+ \+ (V = Min) -> fd_sup(V, Max), ( \+ \+ (V = Max) -> contracting(Vs, Repeat, Vars) ; V #\= Max, contracting(Vs, true, Vars) ) ; V #\= Min, contracting(Vs, true, Vars) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fds_sespsize(Vs, S). S is an upper bound on the search space size with respect to finite domain variables Vs. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ fds_sespsize(Vs, S) :- must_be(list, Vs), maplist(fd_variable, Vs), fds_sespsize(Vs, n(1), S1), bound_portray(S1, S). fd_size_(V, S) :- ( fd_get(V, D, _) -> domain_num_elements(D, S) ; S = n(1) ). fds_sespsize([], S, S). fds_sespsize([V|Vs], S0, S) :- fd_size_(V, S1), S2 cis S0*S1, fds_sespsize(Vs, S2, S). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Optimisation uses the clause database to save the computed extremum over backtracking. Failure is used to get rid of copies of attributed variables that are created in intermediate steps. Example: ?- X in 1..3, call_residue_vars(labeling([min(X)], [X]), Vs). %@ X = 1, Vs = [] %@ ; X = 2, Vs = [] %@ ; X = 3, Vs = [] %@ ; false. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- dynamic(extremum/1). optimise(Vars, Options, Whats) :- Whats = [What|WhatsRest], asserta(extremum(mark)), ( catch(store_extremum(Vars, Options, What), time_limit_exceeded, false) ; once(extremum(Val0)), retract_until_mark, Val0 = n(Val), arg(1, What, Expr), append(WhatsRest, Options, Options1), ( Expr #= Val, labeling(Options1, Vars) ; Expr #\= Val, optimise(Vars, Options, Whats) ) ). retract_until_mark :- ( retract(extremum(E)), E == mark -> true ; retract_until_mark ). store_extremum(Vars, Options, What) :- catch((labeling(Options, Vars), throw(w(What))), w(What1), true), functor(What, Direction, _), maplist(arg(1), [What,What1], [Expr,Expr1]), optimise(Direction, Options, Vars, Expr1, Expr). optimise(Direction, Options, Vars, Expr0, Expr) :- must_be(ground, Expr0), update_extremum(Expr0), catch((tighten(Direction, Expr, Expr0), labeling(Options, Vars), throw(v(Expr))), v(Expr1), true), optimise(Direction, Options, Vars, Expr1, Expr). update_extremum(Expr) :- ( once(extremum(Prev)), Prev = n(_) -> once(retract(extremum(_))) ; true ), asserta(extremum(n(Expr))). tighten(min, E, V) :- E #< V. tighten(max, E, V) :- E #> V. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% all_different(+Vars) % % Like all_distinct/1, but with weaker propagation. all_different(Ls) :- fd_must_be_list(Ls, all_different(Ls)-1), maplist(fd_variable, Ls), Orig = original_goal(_, all_different(Ls)), new_queue(Q0), phrase((all_different(Ls, [], Orig),do_queue), [Q0], _). all_different([], _, _) --> []. all_different([X|Right], Left, Orig) --> ( { var(X) } -> { make_propagator(pdifferent(Left,Right,X,Orig), Prop) }, init_propagator_([X], Prop), trigger_prop(Prop) ; exclude_fire(Left, Right, X) ), all_different(Right, [X|Left], Orig). %% all_distinct(+Vars). % % True iff Vars are pairwise distinct. For example, all_distinct/1 % can detect that not all variables can assume distinct values given % the following domains: % % ``` % ?- maplist(in, Vs, % [1\/3..4, 1..2\/4, 1..2\/4, 1..3, 1..3, 1..6]), % all_distinct(Vs). % false. % ``` all_distinct(Ls) :- fd_must_be_list(Ls, all_distinct(Ls)-1), maplist(fd_variable, Ls), make_propagator(pdistinct(Ls), Prop), new_queue(Q0), phrase((distinct_attach(Ls, Prop, []),trigger_prop(Prop),do_queue), [Q0], _), variables_same_queue(Ls). %% nvalue(?N, +Vars). % % True if N is the number of distinct values taken by Vars. Vars is a % list of domain variables, and N is a domain variable. Can be % thought of as a relaxed version of all_distinct/1. nvalue(N, Vars) :- fd_must_be_list(Vars), maplist(fd_variable, Vars), length(Vars, Len), N in 0..Len, zero_or_more(Vars, N), propagator_init_trigger(Vars, pnvalue(N, Vars)). zero_or_more([], 0). zero_or_more([_|_], N) :- N #> 0. %% sum(+Vars, +Rel, ?Expr) % % The sum of elements of the list Vars is in relation Rel to Expr. % Rel is one of #=, #\=, #<, #>, #=< or #>=. For example: % % ``` % ?- [A,B,C] ins 0..sup, sum([A,B,C], #=, 100). % A in 0..100, % A+B+C#=100, % B in 0..100, % C in 0..100. % ``` sum(Vs, Op, Value) :- must_be(list, Vs), same_length(Vs, Ones), maplist(=(1), Ones), scalar_product(Ones, Vs, Op, Value). %% scalar_product(+Cs, +Vs, +Rel, ?Expr) % % True iff the scalar product of Cs and Vs is in relation Rel to Expr. % Cs is a list of integers, Vs is a list of variables and integers. % Rel is #=, #\=, #<, #>, #=< or #>=. scalar_product(Cs, Vs, Op, Value) :- must_be(list(integer), Cs), must_be(list, Vs), maplist(fd_variable, Vs), ( Op = (#=), single_value(Value, Right), ground(Vs) -> foldl(coeff_int_linsum, Cs, Vs, 0, Right) ; must_be(ground, Op), ( memberchk(Op, [#=,#\=,#<,#>,#=<,#>=]) -> true ; domain_error(scalar_product_relation, Op) ), must_be(acyclic, Value), foldl(coeff_var_plusterm, Cs, Vs, 0, Left), ( left_right_linsum_const(Left, Value, Cs1, Vs1, Const) -> scalar_product_(Op, Cs1, Vs1, Const) ; sum(Cs, Vs, 0, Op, Value) ) ). single_value(V, V) :- var(V), !, non_monotonic(V). single_value(V, V) :- integer(V). single_value(?(V), V) :- fd_variable(V). coeff_var_plusterm(C, V, T0, T0+(C* #V)). coeff_int_linsum(C, I, S0, S) :- S is S0 + C*I. sum([], _, Sum, Op, Value) :- call(Op, Sum, Value). sum([C|Cs], [X|Xs], Acc, Op, Value) :- #NAcc #= Acc + C* #X, sum(Cs, Xs, NAcc, Op, Value). multiples([], [], _). multiples([C|Cs], [V|Vs], Left) :- ( ( Cs = [N|_] ; Left = [N|_] ) -> ( N =\= 1, gcd(C,N) =:= 1 -> gcd(Cs, N, GCD0), gcd(Left, GCD0, GCD), ( GCD > 1 -> #V #= GCD * #_ ; true ) ; true ) ; true ), multiples(Cs, Vs, [C|Left]). abs(N, A) :- A is abs(N). divide(D, N, R) :- R is N // D. scalar_product_(#=, Cs0, Vs, S0) :- ( Cs0 = [C|Rest] -> gcd(Rest, C, GCD), S0 mod GCD =:= 0, maplist(divide(GCD), [S0|Cs0], [S|Cs]) ; S0 =:= 0, S = S0, Cs = Cs0 ), ( S0 =:= 0 -> maplist(abs, Cs, As), multiples(As, Vs, []) ; true ), propagator_init_trigger(Vs, scalar_product_eq(Cs, Vs, S)). scalar_product_(#\=, Cs, Vs, C) :- propagator_init_trigger(Vs, scalar_product_neq(Cs, Vs, C)). scalar_product_(#=<, Cs, Vs, C) :- propagator_init_trigger(Vs, scalar_product_leq(Cs, Vs, C)). scalar_product_(#<, Cs, Vs, C) :- C1 is C - 1, scalar_product_(#=<, Cs, Vs, C1). scalar_product_(#>, Cs, Vs, C) :- C1 is C + 1, scalar_product_(#>=, Cs, Vs, C1). scalar_product_(#>=, Cs, Vs, C) :- maplist(negative, Cs, Cs1), C1 is -C, scalar_product_(#=<, Cs1, Vs, C1). negative(X0, X) :- X is -X0. coeffs_variables_const([], [], [], [], I, I). coeffs_variables_const([C|Cs], [V|Vs], Cs1, Vs1, I0, I) :- ( var(V) -> Cs1 = [C|CRest], Vs1 = [V|VRest], I1 = I0 ; I1 is I0 + C*V, Cs1 = CRest, Vs1 = VRest ), coeffs_variables_const(Cs, Vs, CRest, VRest, I1, I). sum_finite_domains([], [], Inf, Sup, Inf, Sup) ++> []. sum_finite_domains([C|Cs], [V|Vs], Inf0, Sup0, Inf, Sup) ++> { fd_get(V, _, Inf1, Sup1, _) }, ( Inf1 = n(NInf) -> ( C < 0 -> Sup2 is Sup0 + C*NInf ; Inf2 is Inf0 + C*NInf ) ; ( C < 0 -> Sup2 = Sup0, []+[C*V] ; Inf2 = Inf0, [C*V]+[] ) ), ( Sup1 = n(NSup) -> ( C < 0 -> Inf2 is Inf0 + C*NSup ; Sup2 is Sup0 + C*NSup ) ; ( C < 0 -> Inf2 = Inf0, [C*V]+[] ; Sup2 = Sup0, []+[C*V] ) ), sum_finite_domains(Cs, Vs, Inf2, Sup2, Inf, Sup). remove_dist_upper_lower([], _, _, _) --> []. remove_dist_upper_lower([C|Cs], [V|Vs], D1, D2) --> ( { fd_get(V, VD, VPs) } -> ( C < 0 -> { domain_supremum(VD, n(Sup)), L is Sup + D1//C, domain_remove_smaller_than(VD, L, VD1), domain_infimum(VD1, n(Inf)), G is Inf - D2//C, domain_remove_greater_than(VD1, G, VD2) } ; { domain_infimum(VD, n(Inf)), G is Inf + D1//C, domain_remove_greater_than(VD, G, VD1), domain_supremum(VD1, n(Sup)), L is Sup - D2//C, domain_remove_smaller_than(VD1, L, VD2) } ), fd_put(V, VD2, VPs) ; true ), remove_dist_upper_lower(Cs, Vs, D1, D2). remove_dist_upper_leq([], _, _) --> []. remove_dist_upper_leq([C|Cs], [V|Vs], D1) --> ( { fd_get(V, VD, VPs) } -> ( C < 0 -> { domain_supremum(VD, n(Sup)), L is Sup + D1//C, domain_remove_smaller_than(VD, L, VD1) } ; { domain_infimum(VD, n(Inf)), G is Inf + D1//C, domain_remove_greater_than(VD, G, VD1) } ), fd_put(V, VD1, VPs) ; true ), remove_dist_upper_leq(Cs, Vs, D1). remove_dist_upper([], _) --> []. remove_dist_upper([C*V|CVs], D) --> ( { fd_get(V, VD, VPs) } -> ( C < 0 -> ( { domain_supremum(VD, n(Sup)) } -> { L is Sup + D//C, domain_remove_smaller_than(VD, L, VD1) } ; VD1 = VD ) ; ( { domain_infimum(VD, n(Inf)) } -> { G is Inf + D//C, domain_remove_greater_than(VD, G, VD1) } ; VD1 = VD ) ), fd_put(V, VD1, VPs) ; true ), remove_dist_upper(CVs, D). remove_dist_lower([], _) --> []. remove_dist_lower([C*V|CVs], D) --> ( { fd_get(V, VD, VPs) } -> ( C < 0 -> ( { domain_infimum(VD, n(Inf)) } -> { G is Inf - D//C, domain_remove_greater_than(VD, G, VD1) } ; VD1 = VD ) ; ( { domain_supremum(VD, n(Sup)) } -> { L is Sup - D//C, domain_remove_smaller_than(VD, L, VD1) } ; VD1 = VD ) ), fd_put(V, VD1, VPs) ; true ), remove_dist_lower(CVs, D). remove_upper([], _) --> []. remove_upper([C*X|CXs], Max) --> ( { fd_get(X, XD, XPs) } -> D is Max//C, ( C < 0 -> { domain_remove_smaller_than(XD, D, XD1) } ; { domain_remove_greater_than(XD, D, XD1) } ), fd_put(X, XD1, XPs) ; true ), remove_upper(CXs, Max). remove_lower([], _) --> []. remove_lower([C*X|CXs], Min) --> ( { fd_get(X, XD, XPs) } -> D is -Min//C, ( C < 0 -> { domain_remove_greater_than(XD, D, XD1) } ; { domain_remove_smaller_than(XD, D, XD1) } ), fd_put(X, XD1, XPs) ; true ), remove_lower(CXs, Min). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Parsing a CLP() expression has two important side-effects: First, it constrains the variables occurring in the expression to integers. Second, it constrains some of them even more: For example, in X/Y and X mod Y, Y is constrained to be #\= 0. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ constrain_to_integer(Var) :- ( integer(Var) -> true ; fd_get(Var, D, Ps), fd_put(Var, D, Ps) ). power_var_num(P, X, N) :- ( var(P) -> X = P, N = 1 ; P = Left*Right, power_var_num(Left, XL, L), power_var_num(Right, XR, R), XL == XR, X = XL, N is L + R ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Given expression E, we obtain the finite domain variable R by interpreting a simple committed-choice language that is a list of conditions and bodies. In conditions, g(Goal) means literally Goal, and m(Match) means that E can be decomposed as stated. The variables are to be understood as the result of parsing the subexpressions recursively. In the body, g(Goal) means again Goal, and p(Propagator) means to attach and trigger once a propagator. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ :- op(800, xfx, =>). parse_clpz(E, R, [g(cyclic_term(E)) => [g(domain_error(clpz_expression, E))], g(var(E)) => [g(non_monotonic(E)), g(constrain_to_integer(E)), g(E = R)], g(integer(E)) => [g(R = E)], ?(E) => [g(must_be_fd_integer(E)), g(R = E)], #E => [g(must_be_fd_integer(E)), g(R = E)], m(A+B) => [p(pplus(A, B, R))], % power_var_num/3 must occur before */2 to be useful g(power_var_num(E, V, N)) => [p(pexp(V, N, R))], m(A*B) => [p(ptimes(A, B, R))], m(A-B) => [p(pplus(R,B,A))], m(-A) => [p(pplus(A,R,0))], m(max(A,B)) => [g(A #=< #R), g(B #=< R), p(pmax(A, B, R))], m(min(A,B)) => [g(A #>= #R), g(B #>= R), p(pmin(A, B, R))], m(A mod B) => [g(B #\= 0), p(pmod(A, B, R))], m(A rem B) => [g(B #\= 0), p(prem(A, B, R))], m(abs(A)) => [g(#R #>= 0), p(pabs(A, R))], m(A/B) => [g(B #\= 0), p(ptimes(R, B, A))], m(A//B) => [g(B #\= 0), p(ptzdiv(A, B, R))], m(A div B) => [g(#R #= (A - (A mod B)) // B)], m(A^B) => [p(pexp(A, B, R))], m(sign(A)) => [g(R in -1..1), p(psign(A, R))], % bitwise operations m(\A) => [p(pfunction(\, A, R))], m(msb(A)) => [p(pfunction(msb, A, R))], m(lsb(A)) => [p(pfunction(lsb, A, R))], m(popcount(A)) => [p(ppopcount(A, R))], m(A<<B) => [p(pfunction(<<, A, B, R))], m(A>>B) => [p(pfunction(>>, A, B, R))], m(A/\B) => [p(pfunction(/\, A, B, R))], m(A\/B) => [p(pfunction(\/, A, B, R))], m(xor(A, B)) => [p(pxor(A, B, R))], g(true) => [g(domain_error(clpz_expression, E))] ]). non_monotonic(X) :- ( \+ fd_var(X), monotonic -> instantiation_error(X) ; true ). % Here, we compile the committed choice language to a single % predicate, parse_clpz/2. make_parse_clpz(Clauses) :- parse_clpz_clauses(Clauses0), maplist(goals_goal, Clauses0, Clauses). goals_goal((Head :- Goals), (Head :- Body)) :- list_goal(Goals, Body). parse_clpz_clauses(Clauses) :- parse_clpz(E, R, Matchers), maplist(parse_matcher(E, R), Matchers, Clauses). parse_matcher(E, R, Matcher, Clause) :- Matcher = (Condition0 => Goals0), phrase((parse_condition(Condition0, E, Head), parse_goals(Goals0)), Goals), Clause = (parse_clpz(Head, R) :- Goals). parse_condition(g(Goal), E, E) --> [Goal, !]. parse_condition(?(E), _, ?(E)) --> [!]. parse_condition(#E, _, #E) --> [!]. parse_condition(m(Match), _, Match0) --> [!], { copy_term(Match, Match0), term_variables(Match0, Vs0), term_variables(Match, Vs) }, parse_match_variables(Vs0, Vs). parse_match_variables([], []) --> []. parse_match_variables([V0|Vs0], [V|Vs]) --> [parse_clpz(V0, V)], parse_match_variables(Vs0, Vs). parse_goals([]) --> []. parse_goals([G|Gs]) --> parse_goal(G), parse_goals(Gs). parse_goal(g(Goal)) --> [Goal]. parse_goal(p(Prop0)) --> { term_variables(Prop0, Vs), morphing_propagator(Prop0, Prop, _) }, [make_propagator(Prop, P), new_queue(Q0), phrase(init_propagator_(Vs, P), [Q0], [Q]), variables_same_queue(Vs), trigger_once_(P, Q)]. morphing(pplus). morphing(ptimes). morphing(pexp). morphing(ptzdiv). morphing_propagator(P0, P, Target) :- P0 =.. [F|Args0], ( morphing(F) -> append(Args0, [Last], Args), Target = p(Last) ; Args = Args0, Target = none ), P =.. [F|Args]. morph_into_propagator(MState, Vs, P0, Morph) --> kill(MState), { morphing_propagator(P0, P, _), make_propagator(P, Morph) }, init_propagator_(Vs, Morph), trigger_prop(Morph). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ?- use_module(library(lists)), use_module(library(format)), clpz:parse_clpz_clauses(Clauses), maplist(portray_clause, Clauses). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% trigger_once(Prop) :- new_queue(Q), trigger_once_(Prop, Q). trigger_once_(Prop, Q) :- phrase((trigger_prop(Prop),do_queue), [Q], _). neq(A, B) :- propagator_init_trigger(pneq(A, B)). propagator_init_trigger(P) --> { term_variables(P, Vs) }, propagator_init_trigger(Vs, P). propagator_init_trigger(Vs, P) --> [p(Prop)], { make_propagator(P, Prop), new_queue(Q0), phrase(init_propagator_(Vs, Prop), [Q0], [Q]), variables_same_queue(Vs), trigger_once_(Prop, Q) }. variables_same_queue(Vs0) :- include(var, Vs0, Vs), ( Vs == [] -> true ; maplist(variable_queue, Vs, Qs0), sort(Qs0, [Q|Qs]), Q =.. [_|Args], append_queues_(Qs, Args, [append,append,append,ignore]), maplist(clear_queue, Qs), maplist(=(Q), Qs) ). append_queues_([], _, _). append_queues_([Q|Qs], Args0, Is) :- Q =.. [_|Args], maplist(append_queue, Is, Args0, Args), append_queues_(Qs, Args, Is). append_queue(ignore, _, _). append_queue(append, Q0, Q) :- ( get_atts(Q0, queue(Ls0,Ls)) -> ( get_atts(Q, queue(Ms0,Ms)) -> Ls = Ms0, put_atts(Q0, queue(Ls0,Ms)) ; true ) ; ( get_atts(Q, queue(Ms0,Ms)) -> put_atts(Q0, queue(Ms0,Ms)) ; true ) ). clear_queue(queue(Goals,Fast,Slow,Aux)) :- put_atts(Goals, -queue(_,_)), put_atts(Fast, -queue(_,_)), put_atts(Slow, -queue(_,_)), put_atts(Aux, -disabled). variable_queue(Var, Q) :- get_attr(Var, clpz, Attr), Attr = clpz_attr(_Left,_Right,_Spread,_Dom,_Ps,Q). propagator_init_trigger(P) :- phrase(propagator_init_trigger(P), _). propagator_init_trigger(Vs, P) :- phrase(propagator_init_trigger(Vs, P), _). prop_init(Prop, V) :- init_propagator(V, Prop). geq(A, B) :- new_queue(Q), phrase((geq(A, B),do_queue), [Q], _). geq(A, B) --> ( { fd_get(A, AD, APs) } -> { domain_infimum(AD, AI) }, ( { fd_get(B, BD, _) } -> { domain_supremum(BD, BS) }, ( { AI cis_geq BS } -> true ; { propagator_init_trigger(pgeq(A,B)) } ) ; ( { AI cis_geq n(B) } -> true ; { domain_remove_smaller_than(AD, B, AD1) }, fd_put(A, AD1, APs) ) ) ; { fd_get(B, BD, BPs) } -> { domain_remove_greater_than(BD, A, BD1) }, fd_put(B, BD1, BPs) ; A >= B ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Naive parsing of inequalities and disequalities can result in a lot of unnecessary work if expressions of non-trivial depth are involved: Auxiliary variables are introduced for sub-expressions, and propagation proceeds on them as if they were involved in a tighter constraint (like equality), whereas eventually only very little of the propagated information is actually used. For example, only extremal values are of interest in inequalities. Introducing auxiliary variables should be avoided when possible, and specialised propagators should be used for common constraints. We again use a simple committed-choice language for matching special cases of constraints. m_c(M,C) means that M matches and C holds. d(X, Y) means decomposition, i.e., it is short for g(parse_clpz(X, Y)). r(X, Y) means to rematch with X and Y. Two things are important: First, although the actual constraint functors (#\=2, #=/2 etc.) are used in the description, they must expand to the respective auxiliary predicates (match_expand/2) because the actual constraints are subject to goal expansion. Second, when specialised constraints (like scalar product) post simpler constraints on their own, these simpler versions must be handled separately and must occur before. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ match_expand(#>=, clpz_geq_). match_expand(#=, clpz_equal_). match_expand(#\=, clpz_neq). symmetric(#=). symmetric(#\=). matches([ m_c(any(X) #>= any(Y), left_right_linsum_const(X, Y, Cs, Vs, Const)) => [g(( Cs = [1], Vs = [A] -> geq(A, Const) ; Cs = [-1], Vs = [A] -> Const1 is -Const, geq(Const1, A) ; Cs = [1,1], Vs = [A,B] -> #A + #B #= #S, geq(S, Const) ; Cs = [1,-1], Vs = [A,B] -> ( Const =:= 0 -> geq(A, B) ; C1 is -Const, propagator_init_trigger(x_leq_y_plus_c(B, A, C1)) ) ; Cs = [-1,1], Vs = [A,B] -> ( Const =:= 0 -> geq(B, A) ; C1 is -Const, propagator_init_trigger(x_leq_y_plus_c(A, B, C1)) ) ; Cs = [-1,-1], Vs = [A,B] -> #A + #B #= #S, Const1 is -Const, geq(Const1, S) ; scalar_product_(#>=, Cs, Vs, Const) ))], m(any(X) - any(Y) #>= integer(C)) => [d(X, X1), d(Y, Y1), g(C1 is -C), p(x_leq_y_plus_c(Y1, X1, C1))], m(integer(X) #>= any(Z) + integer(A)) => [g(C is X - A), r(C, Z)], m(abs(any(X)-any(Y)) #>= any(Z)) => [d(X, X1), d(Y, Y1), d(Z, Z1), g((abs(#A)#= #B,Y1+A#=X1,Z1#=<B))], m(abs(any(X)) #>= integer(I)) => [d(X, RX), g((I>0 -> I1 is -I, RX in inf..I1 \/ I..sup; true))], m(integer(I) #>= abs(any(X))) => [d(X, RX), g(I>=0), g(I1 is -I), g(RX in I1..I)], m(any(X) #>= any(Y)) => [d(X, RX), d(Y, RY), g(geq(RX, RY))], %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m(var(X) #= var(Y)) => [g(constrain_to_integer(X)), g(X=Y)], m(var(X) #= var(Y)+var(Z)) => [p(pplus(Y,Z,X))], m(var(X) #= var(Y)-var(Z)) => [p(pplus(X,Z,Y))], m(var(X) #= var(Y)*var(Z)) => [p(ptimes(Y,Z,X))], m(var(X) #= -var(Y)) => [p(pplus(X,Y,0))], m_c(any(X) #= any(Y), left_right_linsum_const(X, Y, Cs, Vs, S)) => [g(scalar_product_(#=, Cs, Vs, S))], m_c(var(X) #= abs(var(Y)) + any(V0), X == Y) => [d(V0,V),p(x_eq_abs_plus_v(X,V))], m_c(var(X) #= abs(var(Y)) - any(V0), X == Y) => [d(-V0,V),p(x_eq_abs_plus_v(X,V))], m(var(X) #= any(Y)) => [d(Y,X)], m(any(X) #= any(Y)) => [d(X, RX), d(Y, RX)], %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m(var(X) #\= integer(Y)) => [g(neq_num(X, Y))], m(var(X) #\= var(Y)) => [p(pneq(X,Y))], m(var(X) #\= var(Y) + var(Z)) => [p(x_neq_y_plus_z(X, Y, Z))], m(var(X) #\= var(Y) - var(Z)) => [p(x_neq_y_plus_z(Y, X, Z))], m(var(X) #\= var(Y)*var(Z)) => [p(ptimes(Y,Z,P)), g(neq(X,P))], m(integer(X) #\= abs(any(Y)-any(Z))) => [d(Y, Y1), d(Z, Z1), p(absdiff_neq(Y1, Z1, X))], m_c(any(X) #\= any(Y), left_right_linsum_const(X, Y, Cs, Vs, S)) => [g(scalar_product_(#\=, Cs, Vs, S))], m(any(X) #\= any(Y) + any(Z)) => [d(X, X1), d(Y, Y1), d(Z, Z1), p(x_neq_y_plus_z(X1, Y1, Z1))], m(any(X) #\= any(Y) - any(Z)) => [d(X, X1), d(Y, Y1), d(Z, Z1), p(x_neq_y_plus_z(Y1, X1, Z1))], m(any(X) #\= any(Y)) => [d(X, RX), d(Y, RY), g(neq(RX, RY))] ]). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - We again compile the committed-choice matching language to the intended auxiliary predicates. We now must take care not to unintentionally unify a variable with a complex term. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ make_matches(Clauses) :- matches(Ms), findall(F, (member(M=>_, Ms), arg(1, M, M1), functor(M1, F, _)), Fs0), sort(Fs0, Fs), maplist(prevent_cyclic_argument, Fs, PrevCyclicClauses), phrase(matchers(Ms), Clauses0), maplist(goals_goal, Clauses0, MatcherClauses), append(PrevCyclicClauses, MatcherClauses, Clauses1), sort_by_predicate(Clauses1, Clauses). sort_by_predicate(Clauses, ByPred) :- map_list_to_pairs(predname, Clauses, Keyed), keysort(Keyed, KeyedByPred), pairs_values(KeyedByPred, ByPred). predname((H:-_), Key) :- !, predname(H, Key). predname(M:H, M:Key) :- !, predname(H, Key). predname(H, Name/Arity) :- !, functor(H, Name, Arity). prevent_cyclic_argument(F0, Clause) :- match_expand(F0, F), Head =.. [F,X,Y], Clause = (Head :- ( cyclic_term(X) -> domain_error(clpz_expression, X) ; cyclic_term(Y) -> domain_error(clpz_expression, Y) ; false )). matchers([]) --> []. matchers([Condition => Goals|Ms]) --> matcher(Condition, Goals), matchers(Ms). matcher(m(M), Gs) --> matcher(m_c(M,true), Gs). matcher(m_c(Matcher,Cond), Gs) --> [(Head :- Goals0)], { Matcher =.. [F,A,B], match_expand(F, Expand), Head =.. [Expand,X,Y], phrase((match(A, X), match(B, Y)), Goals0, [Cond,!|Goals1]), phrase(match_goals(Gs, Expand), Goals1) }, ( { symmetric(F), \+ (subsumes_term(A, B), subsumes_term(B, A)) } -> { Head1 =.. [Expand,Y,X] }, [(Head1 :- Goals0)] ; [] ). match(any(A), T) --> [A = T]. match(var(V), T) --> [( nonvar(T), ( T = ?(Var) ; T = #Var ) -> must_be_fd_integer(Var), V = Var ; v_or_i(T), V = T )]. match(integer(I), T) --> [integer(T), I = T]. match(-X, T) --> [nonvar(T), T = -A], match(X, A). match(abs(X), T) --> [nonvar(T), T = abs(A)], match(X, A). match(X+Y, T) --> [nonvar(T), T = A + B], match(X, A), match(Y, B). match(X-Y, T) --> [nonvar(T), T = A - B], match(X, A), match(Y, B). match(X*Y, T) --> [nonvar(T), T = A * B], match(X, A), match(Y, B). match_goals([], _) --> []. match_goals([G|Gs], F) --> match_goal(G, F), match_goals(Gs, F). match_goal(r(X,Y), F) --> { G =.. [F,X,Y] }, [G]. match_goal(d(X,Y), _) --> [parse_clpz(X, Y)]. match_goal(g(Goal), _) --> [Goal]. match_goal(p(Prop0), _) --> { term_variables(Prop0, Vs), morphing_propagator(Prop0, Prop, _) }, [make_propagator(Prop, P), new_queue(Q0), phrase(init_propagator_(Vs, P), [Q0], [Q]), variables_same_queue(Vs), trigger_once_(P, Q)]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% #>=(?X, ?Y) % % Same as Y #=< X. When reasoning over integers, replace (>=)/2 by (#>=)/2 % to obtain more general relations. X #>= Y :- clpz_geq(X, Y). clpz_geq(X, Y) :- clpz_geq_(X, Y), reinforce(X), reinforce(Y). %% #=<(?X, ?Y) % % The arithmetic expression X is less than or equal to Y. When % reasoning over integers, replace (=<)/2 by (#=<)/2 to obtain more % general relations. X #=< Y :- Y #>= X. %% #=(?X, ?Y) % % The arithmetic expression X equals Y. When reasoning over integers, % replace `(is)/2` by `(#=)/2` to obtain more general relations. X #= Y :- clpz_equal(X, Y). clpz_equal(X, Y) :- clpz_equal_(X, Y), reinforce(X). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Conditions under which an equality can be compiled to built-in arithmetic. Their order is significant. (/)/2 becomes (//)/2. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ expr_conds(E, E) --> [integer(E)], { var(E), !, \+ monotonic }. expr_conds(E, E) --> { integer(E) }. expr_conds(?(E), E) --> [integer(E)]. expr_conds(#E, E) --> [integer(E)]. expr_conds(-E0, -E) --> expr_conds(E0, E). expr_conds(abs(E0), abs(E)) --> expr_conds(E0, E). expr_conds(A0+B0, A+B) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(A0*B0, A*B) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(A0-B0, A-B) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(A0//B0, A//B) --> expr_conds(A0, A), expr_conds(B0, B), [B =\= 0]. %expr_conds(A0/B0, AB) --> expr_conds(A0//B0, AB). expr_conds(min(A0,B0), min(A,B)) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(max(A0,B0), max(A,B)) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(A0 mod B0, A mod B) --> expr_conds(A0, A), expr_conds(B0, B), [B =\= 0]. expr_conds(A0^B0, A^B) --> expr_conds(A0, A), expr_conds(B0, B), [(B >= 0 ; A =:= -1)]. % Bitwise operations, added to make CLP() usable in more cases expr_conds(\ A0, \ A) --> expr_conds(A0, A). expr_conds(A0<<B0, A<<B) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(A0>>B0, A>>B) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(A0/\B0, A/\B) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(A0\/B0, A\/B) --> expr_conds(A0, A), expr_conds(B0, B). expr_conds(xor(A0,B0), xor(A,B)) --> expr_conds(A0, A), expr_conds(B0, B). % expr_conds(lsb(A0), lsb(A)) --> expr_conds(A0, A). % expr_conds(msb(A0), msb(A)) --> expr_conds(A0, A). expr_conds(popcount(A0), Count) --> expr_conds(A0, A), [I is A, arithmetic:popcount(I, Count)]. no_popcount_t(Gs, T) :- ( member(arithmetic:popcount(_, _), Gs) -> T = false ; T = true ). clpz_expandable(_ in _). clpz_expandable(_ #= _). clpz_expandable(_ #>= _). clpz_expandable(_ #=< _). clpz_expandable(_ #> _). clpz_expandable(_ #< _). clpz_expandable(_ #\= _). clpz_expandable(_ #<==> _). clpz_expansion(Var in Dom, In) :- ( ground(Dom), Dom = L..U, integer(L), integer(U) -> expansion_simpler( ( integer(Var) -> between:between(L, U, Var) ; clpz:clpz_in(Var, Dom) ), In) ; In = clpz:clpz_in(Var, Dom) ). clpz_expansion(A #<==> B, Reif) :- nonvar(A), A =.. [F0,X0,Y0], clpz_builtin(F0, F), phrase(expr_conds(X0, X), Cs0, Cs), phrase(expr_conds(Y0, Y), Cs), list_goal(Cs0, Cond), Expr =.. [F,X,Y], expansion_simpler(( Cond, ( var(B) ; integer(B), clpz:between(0, 1, B) ) -> ( Expr -> B = 1 ; B = 0 ) ; clpz:reify(A, RA), clpz:reify(B, RA) ), Reif). clpz_expansion(X0 #= Y0, Equal) :- phrase(expr_conds(X0, X), CsX), phrase(expr_conds(Y0, Y), CsY), list_goal(CsX, CondX), list_goal(CsY, CondY), no_popcount_t(CsY, YT), no_popcount_t(CsX, XT), expansion_simpler( ( CondX -> ( YT, var(Y) -> Y is X ; CondY -> X =:= Y ; T is X, clpz:clpz_equal(T, Y0) ) ; CondY -> ( XT, var(X) -> X is Y ; T is Y, clpz:clpz_equal(X0, T) ) ; clpz:clpz_equal(X0, Y0) ), Equal). clpz_expansion(X0 #>= Y0, Geq) :- phrase(expr_conds(X0, X), CsX), phrase(expr_conds(Y0, Y), CsY), list_goal(CsX, CondX), list_goal(CsY, CondY), expansion_simpler( ( CondX -> ( CondY -> X >= Y ; T is X, clpz:clpz_geq(T, Y0) ) ; CondY -> T is Y, clpz:clpz_geq(X0, T) ; clpz:clpz_geq(X0, Y0) ), Geq). clpz_expansion(X #=< Y, Leq) :- clpz_expansion(Y #>= X, Leq). clpz_expansion(X #> Y, Gt) :- clpz_expansion(X #>= Y+1, Gt). clpz_expansion(X #< Y, Lt) :- clpz_expansion(Y #> X, Lt). clpz_expansion(X0 #\= Y0, Neq) :- phrase(expr_conds(X0, X), CsX), phrase(expr_conds(Y0, Y), CsY), list_goal(CsX, CondX), list_goal(CsY, CondY), expansion_simpler( ( CondX -> ( CondY -> X =\= Y ; T is X, clpz:clpz_neq(T, Y0) ) ; CondY -> T is Y, clpz:clpz_neq(X0, T) ; clpz:clpz_neq(X0, Y0) ), Neq). clpz_builtin(#=, =:=). clpz_builtin(#\=, =\=). clpz_builtin(#>, >). clpz_builtin(#<, <). clpz_builtin(#>=, >=). clpz_builtin(#=<, =<). expansion_simpler((True->Then0;_), Then) :- is_true(True), !, expansion_simpler(Then0, Then). expansion_simpler((False->_;Else0), Else) :- is_false(False), !, expansion_simpler(Else0, Else). expansion_simpler((If->Then0;Else0), (If->Then;Else)) :- !, expansion_simpler(Then0, Then), expansion_simpler(Else0, Else). expansion_simpler((A0,B0), (A,B)) :- !, expansion_simpler(A0, A), expansion_simpler(B0, B). expansion_simpler(Var is Expr0, Goal) :- ground(Expr0), !, phrase(expr_conds(Expr0, Expr), Gs), ( maplist(call, Gs) -> Value is Expr, Goal = (Var = Value) ; Goal = false ). expansion_simpler(Var =:= Expr0, Goal) :- ground(Expr0), !, phrase(expr_conds(Expr0, Expr), Gs), ( maplist(call, Gs) -> Value is Expr, Goal = (Var =:= Value) ; Goal = false ). expansion_simpler(between:between(L,U,V), Goal) :- maplist(integer, [L,U,V]), !, ( between(L,U,V) -> Goal = true ; Goal = false ). expansion_simpler(Goal, Goal). is_true(true). is_true(integer(I)) :- integer(I). % :- if(current_predicate(var_property/2)). % is_true(var(X)) :- var(X), var_property(X, fresh(true)). % is_false(integer(X)) :- var(X), var_property(X, fresh(true)). % :- endif. is_false((A,B)) :- is_false(A) ; is_false(B). is_false(var(X)) :- nonvar(X). :- dynamic(goal_expansion/1). user:goal_expansion(Goal0, Goal) :- \+ goal_expansion(false), clpz_expandable(Goal0), clpz_expansion(Goal0, Goal). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% linsum(X, S, S) --> { var(X), !, non_monotonic(X) }, [vn(X,1)]. linsum(I, S0, S) --> { integer(I), S is S0 + I }. linsum(?(X), S, S) --> { must_be_fd_integer(X) }, [vn(X,1)]. linsum(#X, S, S) --> { must_be_fd_integer(X) }, [vn(X,1)]. linsum(-A, S0, S) --> mulsum(A, -1, S0, S). linsum(N*A, S0, S) --> { integer(N) }, !, mulsum(A, N, S0, S). linsum(A*N, S0, S) --> { integer(N) }, !, mulsum(A, N, S0, S). linsum(A+B, S0, S) --> linsum(A, S0, S1), linsum(B, S1, S). linsum(A-B, S0, S) --> linsum(A, S0, S1), mulsum(B, -1, S1, S). mulsum(A, M, S0, S) --> { phrase(linsum(A, 0, CA), As), S is S0 + M*CA }, lin_mul(As, M). lin_mul([], _) --> []. lin_mul([vn(X,N0)|VNs], M) --> { N is N0*M }, [vn(X,N)], lin_mul(VNs, M). v_or_i(V) :- var(V), !, non_monotonic(V). v_or_i(I) :- integer(I). must_be_fd_integer(X) :- ( var(X) -> constrain_to_integer(X) ; must_be(integer, X) ). samsort(Ls0, Ls) :- maplist(as_key, Ls0, LKs0), keysort(LKs0, LKs), maplist(as_key, Ls, LKs). as_key(E, E-t). left_right_linsum_const(Left, Right, Cs, Vs, Const) :- phrase(linsum(Left, 0, CL), Lefts0, Rights), phrase(linsum(Right, 0, CR), Rights0), maplist(linterm_negate, Rights0, Rights), samsort(Lefts0, Lefts), Lefts = [vn(First,N)|LeftsRest], vns_coeffs_variables(LeftsRest, N, First, Cs0, Vs0), filter_linsum(Cs0, Vs0, Cs, Vs), Const is CR - CL. %format("linear sum: ~w ~w ~w\n", [Cs,Vs,Const]). linterm_negate(vn(V,N0), vn(V,N)) :- N is -N0. vns_coeffs_variables([], N, V, [N], [V]). vns_coeffs_variables([vn(V,N)|VNs], N0, V0, Ns, Vs) :- ( V == V0 -> N1 is N0 + N, vns_coeffs_variables(VNs, N1, V0, Ns, Vs) ; Ns = [N0|NRest], Vs = [V0|VRest], vns_coeffs_variables(VNs, N, V, NRest, VRest) ). filter_linsum([], [], [], []). filter_linsum([C0|Cs0], [V0|Vs0], Cs, Vs) :- ( C0 =:= 0 -> constrain_to_integer(V0), filter_linsum(Cs0, Vs0, Cs, Vs) ; Cs = [C0|Cs1], Vs = [V0|Vs1], filter_linsum(Cs0, Vs0, Cs1, Vs1) ). gcd([], G, G). gcd([N|Ns], G0, G) :- G1 is gcd(N, G0), gcd(Ns, G1, G). even(N) :- N mod 2 =:= 0. odd(N) :- \+ even(N). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - k-th root of N, if N is a k-th power. TODO: Replace this when the GMP function becomes available. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ integer_kth_root(N, K, R) :- ( even(K) -> N >= 0 ; true ), ( K < 0 -> ( N =:= 1 -> R = 1 ; N =:= -1 -> odd(K), R = -1 ; false ) ; ( N < 0 -> odd(K), integer_kroot(N, 0, N, K, R) ; integer_kroot(0, N, N, K, R) ) ). integer_kroot(L, U, N, K, R) :- ( L =:= U -> N =:= L^K, R = L ; L + 1 =:= U -> ( L^K =:= N -> R = L ; U^K =:= N -> R = U ; false ) ; Mid is (L + U)//2, ( Mid^K > N -> integer_kroot(L, Mid, N, K, R) ; integer_kroot(Mid, U, N, K, R) ) ). integer_log_b(N, B, Log0, Log) :- T is B^Log0, ( T =:= N -> Log = Log0 ; T < N, Log1 is Log0 + 1, integer_log_b(N, B, Log1, Log) ). floor_integer_log_b(N, B, Log0, Log) :- T is B^Log0, ( T > N -> Log is Log0 - 1 ; T =:= N -> Log = Log0 ; T < N, Log1 is Log0 + 1, floor_integer_log_b(N, B, Log1, Log) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Largest R such that R^K =< N. TODO: Replace this when the GMP function becomes available. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ integer_kth_root_leq(N, K, R) :- ( even(K) -> N >= 0 ; true ), ( N < 0 -> odd(K), integer_kroot_leq(N, 0, N, K, R) ; integer_kroot_leq(0, N, N, K, R) ). integer_kroot_leq(L, U, N, K, R) :- ( L =:= U -> R = L ; L + 1 =:= U -> ( U^K =< N -> R = U ; R = L ) ; Mid is (L + U)//2, ( Mid^K > N -> integer_kroot_leq(L, Mid, N, K, R) ; integer_kroot_leq(Mid, U, N, K, R) ) ). %% #\=(?X, ?Y) % % The arithmetic expressions X and Y evaluate to distinct integers. % When reasoning over integers, replace (=\=)/2 by (#\=)/2 to obtain more % general relations. X #\= Y :- clpz_neq(X, Y). % X #\= Y + Z x_neq_y_plus_z(X, Y, Z) :- propagator_init_trigger(x_neq_y_plus_z(X,Y,Z)). % X is distinct from the number N. This is used internally, and does % not reinforce other constraints. neq_num(X, N) :- ( fd_get(X, XD, XPs) -> domain_remove(XD, N, XD1), fd_put(X, XD1, XPs) ; X =\= N ). neq_num(X, N) --> ( { fd_get(X, XD, XPs) } -> { domain_remove(XD, N, XD1) }, fd_put(X, XD1, XPs) ; X =\= N ). %% #>(?X, ?Y) % % Same as Y #< X. X #> Y :- X #>= Y + 1. %% #<(?X, ?Y) % % The arithmetic expression X is less than Y. When reasoning over % integers, replace `(<)/2` by `(#<)/2` to obtain more general relations. % % In addition to its regular use in tasks that require it, this % constraint can also be useful to eliminate uninteresting symmetries % from a problem. For example, all possible matches between pairs % built from four players in total: % % ``` % ?- Vs = [A,B,C,D], Vs ins 1..4, % all_different(Vs), % A #< B, C #< D, A #< C, % findall(pair(A,B)-pair(C,D), label(Vs), Ms). % Ms = [ pair(1, 2)-pair(3, 4), % pair(1, 3)-pair(2, 4), % pair(1, 4)-pair(2, 3)]. % ``` X #< Y :- Y #> X. %% #\(+Q) % % The reifiable constraint Q does _not_ hold. For example, to obtain % the complement of a domain: % % ``` % ?- #\ X in -3..0\/10..80. % X in inf.. -4\/1..9\/81..sup. % ``` #\ Q :- reify(Q, 0). %% #<==>(?P, ?Q) % % P and Q are equivalent. For example: % % ``` % ?- X #= 4 #<==> B, X #\= 4. % B = 0, % X in inf..3\/5..sup. % ``` % The following example uses reified constraints to relate a list of % finite domain variables to the number of occurrences of a given value: % % ``` % vs_n_num(Vs, N, Num) :- % maplist(eq_b(N), Vs, Bs), % sum(Bs, #=, Num). % % eq_b(X, Y, B) :- X #= Y #<==> B. % ``` % % Sample queries and their results: % % ``` % ?- Vs = [X,Y,Z], Vs ins 0..1, vs_n_num(Vs, 4, Num). % Vs = [X, Y, Z], % Num = 0, % X in 0..1, % Y in 0..1, % Z in 0..1. % % ?- vs_n_num([X,Y,Z], 2, 3). % X = 2, % Y = 2, % Z = 2. % ``` L #<==> R :- reify(L, B), reify(R, B). %% #==>(?P, ?Q) % % P implies Q. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Implication is special in that created auxiliary constraints can be retracted when the implication becomes entailed, for example: %?- X + 1 #= Y #==> Z, Z #= 1. %@ Z = 1, %@ X in inf..sup, %@ Y in inf..sup. We cannot use propagator_init_trigger/1 here because the states of auxiliary propagators are themselves part of the propagator. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ L #==> R :- reify(L, LB, LPs), reify(R, RB, RPs), append(LPs, RPs, Ps), propagator_init_trigger([LB,RB], pimpl(LB,RB,Ps)). %% #<==(?P, ?Q) % % Q implies P. L #<== R :- R #==> L. %% #/\(?P, ?Q) % % P and Q hold. L #/\ R :- reify(L, 1), reify(R, 1). conjunctive_neqs_var_drep(Eqs, Var, Drep) :- conjunctive_neqs_var(Eqs, Var), phrase(conjunctive_neqs_vals(Eqs), Vals), list_to_domain(Vals, Dom), domain_complement(Dom, C), domain_to_drep(C, Drep). conjunctive_neqs_var(V, _) :- var(V), !, false. conjunctive_neqs_var(L #\= R, Var) :- ( var(L), integer(R) -> Var = L ; integer(L), var(R) -> Var = R ; false ). conjunctive_neqs_var(A #/\ B, VA) :- conjunctive_neqs_var(A, VA), conjunctive_neqs_var(B, VB), VA == VB. conjunctive_neqs_vals(L #\= R) --> ( { integer(L) } -> [L] ; [R] ). conjunctive_neqs_vals(A #/\ B) --> conjunctive_neqs_vals(A), conjunctive_neqs_vals(B). %% #\/(?P, ?Q) % % P or Q holds. For example, the sum of natural numbers below 1000 % that are multiples of 3 or 5: % % ``` % ?- findall(N, (N mod 3 #= 0 #\/ N mod 5 #= 0, N in 0..999, % indomain(N)), % Ns), % sum(Ns, #=, Sum). % Ns = [0, 3, 5, 6, 9, 10, 12, 15, 18|...], % Sum = 233168. % ``` L #\/ R :- ( disjunctive_eqs_var_drep(L #\/ R, Var, Drep) -> Var in Drep ; reify(L, X, Ps1), reify(R, Y, Ps2), propagator_init_trigger([X,Y], reified_or(X,Ps1,Y,Ps2,1)) ). disjunctive_eqs_var_drep(Eqs, Var, Drep) :- disjunctive_eqs_var(Eqs, Var), phrase(disjunctive_eqs_vals(Eqs), Vals), list_to_drep(Vals, Drep). disjunctive_eqs_var(V, _) :- var(V), !, false. disjunctive_eqs_var(V in I, V) :- var(V), integer(I). disjunctive_eqs_var(L #= R, Var) :- ( var(L), integer(R) -> Var = L ; integer(L), var(R) -> Var = R ; false ). disjunctive_eqs_var(A #\/ B, VA) :- disjunctive_eqs_var(A, VA), disjunctive_eqs_var(B, VB), VA == VB. disjunctive_eqs_vals(L #= R) --> ( { integer(L) } -> [L] ; [R] ). disjunctive_eqs_vals(_ in I) --> [I]. disjunctive_eqs_vals(A #\/ B) --> disjunctive_eqs_vals(A), disjunctive_eqs_vals(B). %% #\(?P, ?Q) % % Either P holds or Q holds, but not both. L #\ R :- (L #\/ R) #/\ #\ (L #/\ R). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A constraint that is being reified need not hold. Therefore, in X/Y, Y can as well be 0, for example. Note that it is OK to constrain the *result* of an expression (which does not appear explicitly in the expression and is not visible to the outside), but not the operands, except for requiring that they be integers. In contrast to parse_clpz/2, the result of an expression can now also be undefined, in which case the constraint cannot hold. Therefore, the committed-choice language is extended by an element d(D) that states D is 1 iff all subexpressions are defined. a(V) means that V is an auxiliary variable that was introduced while parsing a compound expression. a(X,V) means V is auxiliary unless it is (==)/2 X, and a(X,Y,V) means V is auxiliary unless it is (==)/2 X or Y. l(L) means the literal L occurs in the described list, and ls(Ls) means the literals Ls occur in the described list. When a constraint becomes entailed or subexpressions become undefined, created auxiliary constraints are killed, and the "clpz" attribute is removed from auxiliary variables. For (//)/2, (mod)/2 and (rem)/2, we create a skeleton propagator and remember it as an auxiliary constraint. The pskeleton propagator can use the skeleton when the constraint is defined. We cannot use a skeleton propagator for (/)/2, since (/)/2 can fail in cases such as 0 #==> X #= 1/2, where we expect success. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ parse_reified(E, R, D, [g(cyclic_term(E)) => [g(domain_error(clpz_expression, E))], g(var(E)) => [g(non_monotonic(E)), g(constrain_to_integer(E)), g(R = E), g(D=1)], g(integer(E)) => [g(R=E), g(D=1)], ?(E) => [g(must_be_fd_integer(E)), g(R=E), g(D=1)], #E => [g(must_be_fd_integer(E)), g(R=E), g(D=1)], m(A+B) => [d(D), p(pplus(A,B,R)), a(A,B,R)], m(A*B) => [d(D), p(ptimes(A,B,R)), a(A,B,R)], m(A-B) => [d(D), p(pplus(R,B,A)), a(A,B,R)], m(-A) => [d(D), p(pplus(A,R,0)), a(R)], m(max(A,B)) => [d(D), p(pgeq(R, A)), p(pgeq(R, B)), p(pmax(A,B,R)), a(A,B,R)], m(min(A,B)) => [d(D), p(pgeq(A, R)), p(pgeq(B, R)), p(pmin(A,B,R)), a(A,B,R)], m(abs(A)) => [d(D), g(#R#>=0), p(pabs(A, R)), a(A,R)], m(A^B) => [d(D1), p(preified_exp(A,B,D2,R)), p(reified_and(D1,[],D2,[],D)),a(D2),a(A,B,R)], m(A/B) => [d(D1), p(preified_slash(A,B,D2,R)), p(reified_and(D1,[],D2,[],D)),a(D2),a(A,B,R)], m(A div B) => [d(D1), g(phrase(parse_reified_clpz(((A-(A mod B)) // B), R, D2), Ps)), ls(Ps), p(reified_and(D1,[],D2,[],D)),a(D2),a(A,B,R)], m(A//B) => [skeleton(A,B,D,R,ptzdiv)], m(A mod B) => [skeleton(A,B,D,R,pmod)], m(A rem B) => [skeleton(A,B,D,R,prem)], % bitwise operations m(\A) => [function(D,\,A,R)], m(msb(A)) => [g(#A#>0) ,function(D,msb,A,R)], m(lsb(A)) => [g(#A#>0), function(D,lsb,A,R)], m(popcount(A)) => [d(D), p(ppopcount(A, R)), a(A,R)], m(sign(A)) => [d(D), p(psign(A, R)), a(A,R)], m(A<<B) => [function(D,<<,A,B,R)], m(A>>B) => [function(D,>>,A,B,R)], m(A/\B) => [function(D,/\,A,B,R)], m(A\/B) => [function(D,\/,A,B,R)], m(xor(A, B)) => [skeleton(A,B,D,R,pxor)], g(true) => [g(domain_error(clpz_expression, E))]] ). % Again, we compile this to a predicate, parse_reified_clpz//3. This % time, it is a DCG that describes the list of auxiliary variables and % propagators for the given expression, in addition to relating it to % its reified (Boolean) finite domain variable and its Boolean % definedness. make_parse_reified(Clauses) :- parse_reified_clauses(Clauses0), maplist(goals_goal_dcg, Clauses0, Clauses). goals_goal_dcg((Head --> Goals), Clause) :- list_goal(Goals, Body), expand_term((Head --> Body), Clause). parse_reified_clauses(Clauses) :- parse_reified(E, R, D, Matchers), maplist(parse_reified(E, R, D), Matchers, Clauses). parse_reified(E, R, D, Matcher, Clause) :- Matcher = (Condition0 => Goals0), phrase((reified_condition(Condition0, E, Head, Ds), reified_goals(Goals0, Ds)), Goals, [a(D)]), Clause = (parse_reified_clpz(Head, R, D) --> Goals). reified_condition(g(Goal), E, E, []) --> [{Goal}, !]. reified_condition(?(E), _, ?(E), []) --> [!]. reified_condition(#E, _, #E, []) --> [!]. reified_condition(m(Match), _, Match0, Ds) --> [!], { copy_term(Match, Match0), term_variables(Match0, Vs0), term_variables(Match, Vs) }, reified_variables(Vs0, Vs, Ds). reified_variables([], [], []) --> []. reified_variables([V0|Vs0], [V|Vs], [D|Ds]) --> [parse_reified_clpz(V0, V, D)], reified_variables(Vs0, Vs, Ds). reified_goals([], _) --> []. reified_goals([G|Gs], Ds) --> reified_goal(G, Ds), reified_goals(Gs, Ds). reified_goal(d(D), Ds) --> ( { Ds = [X] } -> [{D=X}] ; { Ds = [X,Y] } -> { phrase(reified_goal(p(reified_and(X,[],Y,[],D)), _), Gs), list_goal(Gs, Goal) }, [( {X==1, Y==1} -> {D = 1} ; Goal )] ; { domain_error(one_or_two_element_list, Ds) } ). reified_goal(g(Goal), _) --> [{Goal}]. reified_goal(p(Vs, Prop0), _) --> { morphing_propagator(Prop0, Prop, Target) }, [{make_propagator(Prop, P)}], target_propagator(Target), parse_init_dcg(Vs, P), [{variables_same_queue(Vs), trigger_once(P)}], [( { propagator_state(P, S), S == dead } -> [] ; [p(P)])]. reified_goal(p(Prop), Ds) --> { term_variables(Prop, Vs) }, reified_goal(p(Vs,Prop), Ds). reified_goal(function(D,Op,A,B,R), Ds) --> reified_goals([d(D),p(pfunction(Op,A,B,R)),a(A,B,R)], Ds). reified_goal(function(D,Op,A,R), Ds) --> reified_goals([d(D),p(pfunction(Op,A,R)),a(A,R)], Ds). reified_goal(skeleton(A,B,D,R,F), Ds) --> { Prop0 =.. [F,X,Y,Z], morphing_propagator(Prop0, Prop, Target) }, target_propagator(Target), reified_goals([d(D1),l(p(P)),g(make_propagator(Prop, P)), p([A,B,D2,R], pskeleton(A,B,D2,[X,Y,Z]-P,R,F)), p(reified_and(D1,[],D2,[],D)),a(D2),a(A,B,R)], Ds). reified_goal(a(V), _) --> [a(V)]. reified_goal(a(X,V), _) --> [a(X,V)]. reified_goal(a(X,Y,V), _) --> [a(X,Y,V)]. reified_goal(l(L), _) --> [[L]]. reified_goal(ls(Ls), _) --> [Ls]. target_propagator(p(Prop)) --> [[p(Prop)]]. target_propagator(none) --> []. parse_init_dcg([], _) --> []. parse_init_dcg([V|Vs], P) --> [{init_propagator(V, P)}], parse_init_dcg(Vs, P). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ?- use_module(library(lists)), use_module(library(format)), clpz:parse_reified_clauses(Cs), maplist(portray_clause, Cs). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ reify(E, B) :- reify(E, B, _). reify(Expr, B, Ps) :- ( acyclic_term(Expr), reifiable(Expr) -> phrase(reify(Expr, B), Ps) ; domain_error(clpz_reifiable_expression, Expr) ). reifiable(E) :- var(E), non_monotonic(E). reifiable(E) :- integer(E), E in 0..1. reifiable(?(E)) :- must_be_fd_integer(E). reifiable(#E) :- must_be_fd_integer(E). reifiable(V in _) :- fd_variable(V). reifiable(Expr) :- Expr =.. [Op,Left,Right], ( memberchk(Op, [#>=,#>,#=<,#<,#=,#\=]) ; memberchk(Op, [#==>,#<==,#<==>,#/\,#\/,#\]), reifiable(Left), reifiable(Right) ). reifiable(#\ E) :- reifiable(E). reifiable(tuples_in(Tuples, Relation)) :- must_be(list(list), Tuples), maplist(maplist(fd_variable), Tuples), must_be(list(list(integer)), Relation). reifiable(finite_domain(V)) :- fd_variable(V). reify(E, B) --> { B in 0..1 }, reify_(E, B). reify_(E, B) --> { var(E), !, E = B }. reify_(E, B) --> { integer(E), E = B }. reify_(?(B), B) --> []. reify_(#B, B) --> []. reify_(V in Drep, B) --> { drep_to_domain(Drep, Dom) }, propagator_init_trigger(reified_in(V,Dom,B)), a(B). reify_(tuples_in(Tuples, Relation), B) --> { maplist(relation_tuple_b_prop(Relation), Tuples, Bs, Ps), maplist(monotonic, Bs, Bs1), fold_statement(conjunction, Bs1, And), #B #<==> And }, propagator_init_trigger([B], tuples_not_in(Tuples, Relation, B)), kill_reified_tuples(Bs, Ps, Bs), seq(Ps), as([B|Bs]). reify_(finite_domain(V), B) --> propagator_init_trigger(reified_fd(V,B)), a(B). reify_(L #>= R, B) --> arithmetic(L, R, B, reified_geq). reify_(L #= R, B) --> arithmetic(L, R, B, reified_eq). reify_(L #\= R, B) --> arithmetic(L, R, B, reified_neq). reify_(L #> R, B) --> reify_(L #>= (R+1), B). reify_(L #=< R, B) --> reify_(R #>= L, B). reify_(L #< R, B) --> reify_(R #>= (L+1), B). reify_(L #==> R, B) --> reify_((#\ L) #\/ R, B). reify_(L #<== R, B) --> reify_(R #==> L, B). reify_(L #<==> R, B) --> reify_((L #==> R) #/\ (R #==> L), B). reify_(L #\ R, B) --> reify_((L #\/ R) #/\ #\ (L #/\ R), B). reify_(L #/\ R, B) --> ( { conjunctive_neqs_var_drep(L #/\ R, V, D) } -> reify_(V in D, B) ; boolean(L, R, B, reified_and) ). reify_(L #\/ R, B) --> ( { disjunctive_eqs_var_drep(L #\/ R, V, D) } -> reify_(V in D, B) ; boolean(L, R, B, reified_or) ). reify_(#\ Q, B) --> reify(Q, QR), propagator_init_trigger(reified_not(QR,B)), a(B). arithmetic(L, R, B, Functor) --> { phrase((parse_reified_clpz(L, LR, LD), parse_reified_clpz(R, RR, RD)), Ps), Prop =.. [Functor,LD,LR,RD,RR,Ps,B] }, seq(Ps), propagator_init_trigger([LD,LR,RD,RR,B], Prop), a(B). boolean(L, R, B, Functor) --> { reify(L, LR, Ps1), reify(R, RR, Ps2), Prop =.. [Functor,LR,Ps1,RR,Ps2,B] }, seq(Ps1), seq(Ps2), propagator_init_trigger([LR,RR,B], Prop), a(LR, RR, B). a(X,Y,B) --> ( nonvar(X) -> a(Y, B) ; nonvar(Y) -> a(X, B) ; [a(X,Y,B)] ). a(X, B) --> ( { var(X) } -> [a(X, B)] ; a(B) ). a(B) --> ( { var(B) } -> [a(B)] ; [] ). as([]) --> []. as([B|Bs]) --> a(B), as(Bs). kill_reified_tuples([], _, _) --> []. kill_reified_tuples([B|Bs], Ps, All) --> propagator_init_trigger([B], kill_reified_tuples(B, Ps, All)), kill_reified_tuples(Bs, Ps, All). relation_tuple_b_prop(Relation, Tuple, B, p(Prop)) :- put_attr(R, clpz_relation, Relation), make_propagator(reified_tuple_in(Tuple, R, B), Prop), new_queue(Q0), phrase((tuple_freeze_(Tuple, Prop), init_propagator_([B], Prop), do_queue), [Q0], _). tuples_in_conjunction(Tuples, Relation, Conj) :- maplist(tuple_in_disjunction(Relation), Tuples, Disjs), fold_statement(conjunction, Disjs, Conj). tuple_in_disjunction(Relation, Tuple, Disj) :- maplist(tuple_in_conjunction(Tuple), Relation, Conjs), fold_statement(disjunction, Conjs, Disj). tuple_in_conjunction(Tuple, Element, Conj) :- maplist(var_eq, Tuple, Element, Eqs), fold_statement(conjunction, Eqs, Conj). fold_statement(Operation, List, Statement) :- ( List = [] -> Statement = 1 ; List = [First|Rest], foldl(Operation, Rest, First, Statement) ). conjunction(E, Conj, Conj #/\ E). disjunction(E, Disj, Disj #\/ E). var_eq(V, N, #V #= N). % Match variables to created skeleton. skeleton(Vs, Vs-Prop) :- ( propagator_state(Prop, State), State == dead -> true ; maplist(prop_init(Prop), Vs), trigger_once(Prop) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A drep is a user-accessible and visible domain representation. N, N..M, and D1 \/ D2 are dreps, if D1 and D2 are dreps. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ is_drep(N) :- integer(N). is_drep(N..M) :- drep_bound(N), drep_bound(M), N \== sup, M \== inf. is_drep(D1\/D2) :- is_drep(D1), is_drep(D2). is_drep({AI}) :- is_and_integers(AI). is_drep(\D) :- is_drep(D). is_and_integers(I) :- integer(I). is_and_integers((A,B)) :- is_and_integers(A), is_and_integers(B). drep_bound(I) :- integer(I). drep_bound(sup). drep_bound(inf). drep_to_intervals(I) --> { integer(I) }, [n(I)-n(I)]. drep_to_intervals(N..M) --> ( { defaulty_to_bound(N, N1), defaulty_to_bound(M, M1), N1 cis_leq M1} -> [N1-M1] ; [] ). drep_to_intervals(D1 \/ D2) --> drep_to_intervals(D1), drep_to_intervals(D2). drep_to_intervals(\D0) --> { drep_to_domain(D0, D1), domain_complement(D1, D), domain_to_drep(D, Drep) }, drep_to_intervals(Drep). drep_to_intervals({AI}) --> and_integers_(AI). and_integers_(I) --> { integer(I) }, [n(I)-n(I)]. and_integers_((A,B)) --> and_integers_(A), and_integers_(B). drep_to_domain(DR, D) :- must_be(ground, DR), ( is_drep(DR) -> true ; domain_error(clpz_domain, DR) ), phrase(drep_to_intervals(DR), Is0), merge_intervals(Is0, Is1), intervals_to_domain(Is1, D). merge_intervals(Is0, Is) :- keysort(Is0, Is1), merge_overlapping(Is1, Is). merge_overlapping([], []). merge_overlapping([A-B0|ABs0], [A-B|ABs]) :- merge_remaining(ABs0, B0, B, Rest), merge_overlapping(Rest, ABs). merge_remaining([], B, B, []). merge_remaining([N-M|NMs], B0, B, Rest) :- Next cis B0 + n(1), ( N cis_gt Next -> B = B0, Rest = [N-M|NMs] ; B1 cis max(B0,M), merge_remaining(NMs, B1, B, Rest) ). domain(V, Dom) :- ( fd_get(V, Dom0, VPs) -> domains_intersection(Dom, Dom0, Dom1), %format("intersected\n: ~w\n ~w\n==> ~w\n\n", [Dom,Dom0,Dom1]), fd_put(V, Dom1, VPs), reinforce(V) ; domain_contains(Dom, V) ). domains([], _). domains([V|Vs], D) :- domain(V, D), domains(Vs, D). props_number(fd_props(Gs,Bs,Os), N) :- length(Gs, N1), length(Bs, N2), length(Os, N3), N is N1 + N2 + N3. fd_get(X, Dom, Ps) :- ( get_attr(X, clpz, Attr) -> Attr = clpz_attr(_,_,_,Dom,Ps,_) ; var(X) -> default_domain(Dom), Ps = fd_props([],[],[]) ). fd_get(X, Dom, Inf, Sup, Ps) :- fd_get(X, Dom, Ps), domain_infimum(Dom, Inf), domain_supremum(Dom, Sup). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Constraint propagation always terminates. Currently, this is ensured by allowing the left and right boundaries, as well as the distance between the smallest and largest number occurring in the domain representation to be changed at most once after a constraint is posted, unless the domain is bounded. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ fd_put(X, Dom, Ps) --> put_terminating(X, Dom, Ps). fd_put(X, Dom, Ps) :- new_queue(Q), phrase((put_terminating(X, Dom, Ps), % { portray_clause(done_terminating) }, do_queue), [Q], _). put_terminating(X, Dom, Ps) --> Dom \== empty, ( Dom = from_to(F, F) -> queue_goal(F = n(X)) ; ( { get_attr(X, clpz, Attr) } -> { Attr = clpz_attr(Left,Right,Spread,OldDom, _OldPs,Q), put_attr(X, clpz, clpz_attr(Left,Right,Spread,Dom,Ps,Q)) }, ( { OldDom == Dom } -> [] ; { ( Left == (.) -> Bounded = yes ; domain_infimum(Dom, Inf), domain_supremum(Dom, Sup), ( Inf = n(_), Sup = n(_) -> Bounded = yes ; Bounded = no ) ) }, ( { Bounded == yes } -> { put_attr(X, clpz, clpz_attr(.,.,.,Dom,Ps,Q)) }, trigger_props(Ps, X, OldDom, Dom) ; % infinite domain; consider border and spread changes { domain_infimum(OldDom, OldInf), ( Inf == OldInf -> LeftP = Left ; LeftP = yes ), domain_supremum(OldDom, OldSup), ( Sup == OldSup -> RightP = Right ; RightP = yes ), domain_spread(OldDom, OldSpread), domain_spread(Dom, NewSpread), ( NewSpread == OldSpread -> SpreadP = Spread ; NewSpread cis_lt OldSpread -> SpreadP = no ; SpreadP = yes ), put_attr(X, clpz, clpz_attr(LeftP,RightP,SpreadP,Dom,Ps,Q)) }, ( { RightP == yes, Right = yes } -> [] ; { LeftP == yes, Left = yes } -> [] ; { SpreadP == yes, Spread = yes } -> [] ; trigger_props(Ps, X, OldDom, Dom) ) ) ) ; { var(X) } -> { new_queue(Q), put_attr(X, clpz, clpz_attr(no,no,no,Dom,Ps,Q)) } ; [] ) ). new_queue(queue(_Goals,_Fast,_Slow,_Aux)). queue_goal(Goal) --> insert_queue(Goal, 1). queue_fast(Prop) --> insert_queue(Prop, 2). queue_slow(Prop) --> insert_queue(Prop, 3). insert_queue(Element, Which) --> state(Queue), { arg(Which, Queue, Arg), ( get_atts(Arg, queue(Head0,Tail0)) -> Head = Head0, Tail0 = [Element|Tail] ; Head = [Element|Tail] ), put_atts(Arg, queue(Head,Tail)) }. domain_spread(Dom, Spread) :- domain_smallest_finite(Dom, S), domain_largest_finite(Dom, L), Spread cis L - S. smallest_finite(inf, Y, Y). smallest_finite(n(N), _, n(N)). domain_smallest_finite(from_to(F,T), S) :- smallest_finite(F, T, S). domain_smallest_finite(split(_, L, _), S) :- domain_smallest_finite(L, S). largest_finite(sup, Y, Y). largest_finite(n(N), _, n(N)). domain_largest_finite(from_to(F,T), L) :- largest_finite(T, F, L). domain_largest_finite(split(_, _, R), L) :- domain_largest_finite(R, L). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - All relevant constraints get a propagation opportunity whenever a new constraint is posted. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ reinforce(X) :- term_variables(X, Vs), maplist(reinforce_, Vs). reinforce_(X) :- ( fd_var(X), fd_get(X, Dom, Ps) -> put_full(X, Dom, Ps) ; true ). put_full(X, Dom, Ps) :- Dom \== empty, ( Dom = from_to(F, F) -> F = n(X) ; ( get_attr(X, clpz, Attr) -> Attr = clpz_attr(_,_,_,OldDom, _OldPs,Q), put_attr(X, clpz, clpz_attr(no,no,no,Dom,Ps,Q)), %format("putting dom: ~w\n", [Dom]), ( OldDom == Dom -> true ; new_queue(Q), % TODO: queue? phrase((trigger_props(Ps, X, OldDom, Dom), do_queue), [Q], _) ) ; var(X) -> %format('\t~w in ~w .. ~w\n',[X,L,U]), new_queue(Q), put_attr(X, clpz, clpz_attr(no,no,no,Dom,Ps,Q)) ; true ) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A propagator is a term of the form propagator(C, State), where C represents a constraint, and State is a free variable that can be used to destructively change the state of the propagator via attributes. This can be used to avoid redundant invocation of the same propagator, or to disable the propagator. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ make_propagator(C, propagator(C, _)). propagator_state(propagator(_,S), S). trigger_props(fd_props(Gs,Bs,Os), X, D0, D) --> ( { ground(X) } -> trigger_props_(Gs), trigger_props_(Bs) ; Bs \== [] -> { domain_infimum(D0, I0), domain_infimum(D, I) }, ( { I == I0 } -> { domain_supremum(D0, S0), domain_supremum(D, S) }, ( { S == S0 } -> [] ; trigger_props_(Bs) ) ; trigger_props_(Bs) ) ; [] ), trigger_props_(Os). trigger_props(fd_props(Gs,Bs,Os), X) --> trigger_props_(Os), trigger_props_(Bs), ( { ground(X) } -> trigger_props_(Gs) ; [] ). trigger_props(fd_props(Gs,Bs,Os)) --> trigger_props_(Gs), trigger_props_(Bs), trigger_props_(Os). trigger_props_([]) --> []. trigger_props_([P|Ps]) --> trigger_prop(P), trigger_props_(Ps). trigger_prop(P) :- trigger_once(P). trigger_prop(Propagator) --> { propagator_state(Propagator, State) }, ( { State == dead } -> [] ; { get_attr(State, clpz_aux, queued) } -> [] ; { bb_get('$clpz_current_propagator', C), C == State } -> [] ; % passive %{ format("triggering: ~w\n", [Propagator]) }, { put_attr(State, clpz_aux, queued) }, ( { arg(1, Propagator, C), functor(C, F, _), global_constraint(F) } -> queue_slow(Propagator) ; queue_fast(Propagator) ) ). all_propagators(fd_props(Gs,Bs,Os)) --> propagators_(Gs), propagators_(Bs), propagators_(Os). propagators_([]) --> []. propagators_([P|Ps]) --> propagator_(P), propagators_(Ps). propagator_(Propagator) --> { propagator_state(Propagator, State) }, ( { State == dead } -> [] ; { get_attr(State, clpz_aux, queued) } -> [] ; % passive % format("triggering: ~w\n", [Propagator]), [clpz:trigger_prop(Propagator)] ). % DCG variants kill(State) --> { kill(State) }. kill(State, Ps) --> { kill(State, Ps) }. T =.. Ls --> { T =.. Ls }. A = A --> []. A == B --> { A == B }. A \== B --> { A \== B }. integer(I) --> { integer(I) }. nonvar(X) --> { nonvar(X) }. var(V) --> { var(V) }. ground(T) --> { ground(T) }. true --> []. false --> { false }. X >= Y --> { X >= Y }. X =< Y --> { X =< Y }. X =:= Y --> { X =:= Y }. X =\= Y --> { X =\= Y }. X is E --> { X is E }. X > Y --> { X > Y }. X < Y --> { X < Y }. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Duo DCG variants - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ A = B ++> { A = B }. A < B ++> { A < B }. A is B ++> { A is B }. kill(State) :- del_attr(State, clpz_aux), State = dead. kill(State, Ps) :- kill(State), maplist(kill_entailed, Ps). kill_entailed(p(Prop)) :- propagator_state(Prop, State), kill(State). kill_entailed(a(V)) :- del_attr(V, clpz). kill_entailed(a(X,B)) :- ( X == B -> true ; del_attr(B, clpz) ). kill_entailed(a(X,Y,B)) :- ( X == B -> true ; Y == B -> true ; del_attr(B, clpz) ). no_reactivation(rel_tuple(_,_)). no_reactivation(pdistinct(_)). no_reactivation(pnvalue(_)). no_reactivation(pgcc(_,_,_)). no_reactivation(pgcc_single(_,_)). %no_reactivation(scalar_product(_,_,_,_)). activate_propagator(propagator(P,State)) --> % { portray_clause(running(P)) }, ( State == dead -> [] ; { del_attr(State, clpz_aux) }, ( { no_reactivation(P) } -> { bb_b_put('$clpz_current_propagator', State) }, run_propagator(P, State), { bb_b_put('$clpz_current_propagator', []) } ; run_propagator(P, State) ) ). %do_queue --> print_queue, false. do_queue --> ( queue_enabled -> ( queue_get_goal(Goal) -> { call(Goal) }, do_queue ; queue_get_fast(Fast) -> activate_propagator(Fast), do_queue ; queue_get_slow(Slow) -> activate_propagator(Slow), do_queue ; true ) ; true ). :- meta_predicate(ignore(0)). ignore(Goal) :- ( Goal -> true ; true ). print_queue --> state(queue(Goal,Fast,Slow,_)), { ignore(get_atts(Goal, queue(GHs,_))), ignore(get_atts(Fast, queue(FHs,_))), ignore(get_atts(Slow, queue(SHs,_))), format("Current queue:~n goal: ~q~n fast: ~q~n slow: ~q~n~n", [GHs,FHs,SHs]) }. queue_get_goal(Goal) --> queue_get_arg(1, Goal). queue_get_fast(Fast) --> queue_get_arg(2, Fast). queue_get_slow(Slow) --> queue_get_arg(3, Slow). queue_get_arg(Which, Element) --> state(Queue), { queue_get_arg_(Queue, Which, Element) }. queue_get_arg_(Queue, Which, Element) :- arg(Which, Queue, Arg), get_atts(Arg, queue([Element|Elements],Tail)), ( var(Elements) -> put_atts(Arg, -queue(_,_)) ; put_atts(Arg, queue(Elements,Tail)) ). queue_enabled --> state(queue(_,_,_,Aux)), { \+ get_atts(Aux, disabled) }. disable_queue --> state(queue(_,_,_,Aux)), { put_atts(Aux, disabled) }. enable_queue --> state(queue(_,_,_,Aux)), { put_atts(Aux, -disabled) }. portray_propagator(propagator(P,_), F) :- functor(P, F, _). init_propagator_([], _) --> []. init_propagator_([V|Vs], Prop) --> ( { fd_get(V, Dom, Ps0) } -> { insert_propagator(Prop, Ps0, Ps) }, fd_put(V, Dom, Ps) ; [] ), init_propagator_(Vs, Prop). init_propagator(Var, Prop) :- ( fd_get(Var, Dom, Ps0) -> insert_propagator(Prop, Ps0, Ps), fd_put(Var, Dom, Ps) ; true ). constraint_wake(pneq, ground). constraint_wake(x_neq_y_plus_z, ground). constraint_wake(absdiff_neq, ground). constraint_wake(pdifferent, ground). constraint_wake(pexclude, ground). constraint_wake(scalar_product_neq, ground). constraint_wake(x_eq_abs_plus_v, ground). constraint_wake(x_leq_y_plus_c, bounds). constraint_wake(scalar_product_eq, bounds). constraint_wake(scalar_product_leq, bounds). constraint_wake(pplus, bounds). constraint_wake(pgeq, bounds). constraint_wake(pgcc_single, bounds). constraint_wake(pgcc_check_single, bounds). global_constraint(pdistinct). global_constraint(pnvalue). global_constraint(pgcc). global_constraint(pgcc_single). global_constraint(pcircuit). %global_constraint(rel_tuple). %global_constraint(scalar_product_eq). insert_propagator(Prop, Ps0, Ps) :- Ps0 = fd_props(Gs,Bs,Os), arg(1, Prop, Constraint), functor(Constraint, F, _), ( constraint_wake(F, ground) -> Ps = fd_props([Prop|Gs], Bs, Os) ; constraint_wake(F, bounds) -> Ps = fd_props(Gs, [Prop|Bs], Os) ; Ps = fd_props(Gs, Bs, [Prop|Os]) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% lex_chain(+Lists) % % Lists are lexicographically non-decreasing. lex_chain(Lss) :- must_be(list(list), lex_chain(Lss)-1, Lss), maplist(maplist(fd_variable), Lss), ( Lss == [] -> true ; Lss = [First|Rest], make_propagator(presidual(lex_chain(Lss)), Prop), foldl(lex_chain_(Prop), Rest, First, _) ). lex_chain_(Prop, Ls, Prev, Ls) :- maplist(prop_init(Prop), Ls), lex_le(Prev, Ls). lex_le([], []). lex_le([V1|V1s], [V2|V2s]) :- #V1 #=< #V2, ( integer(V1) -> ( integer(V2) -> ( V1 =:= V2 -> lex_le(V1s, V2s) ; true ) ; freeze(V2, lex_le([V1|V1s], [V2|V2s])) ) ; freeze(V1, lex_le([V1|V1s], [V2|V2s])) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% tuples_in(+Tuples, +Relation). % % True iff all Tuples are elements of Relation. Each element of the % list Tuples is a list of integers or finite domain variables. % Relation is a list of lists of integers. Arbitrary finite relations, % such as compatibility tables, can be modeled in this way. For % example, if 1 is compatible with 2 and 5, and 4 is compatible with 0 % and 3: % % ``` % ?- tuples_in([[X,Y]], [[1,2],[1,5],[4,0],[4,3]]), X = 4. % X = 4, % Y in 0\/3. % ``` % % As another example, consider a train schedule represented as a list % of quadruples, denoting departure and arrival places and times for % each train. In the following program, Ps is a feasible journey of % length 3 from A to D via trains that are part of the given schedule. % % ``` % trains([[1,2,0,1], % [2,3,4,5], % [2,3,0,1], % [3,4,5,6], % [3,4,2,3], % [3,4,8,9]]). % % threepath(A, D, Ps) :- % Ps = [[A,B,_T0,T1],[B,C,T2,T3],[C,D,T4,_T5]], % T2 #> T1, % T4 #> T3, % trains(Ts), % tuples_in(Ps, Ts). % ``` % % In this example, the unique solution is found without labeling: % % ``` % ?- threepath(1, 4, Ps). % Ps = [[1, 2, 0, 1], [2, 3, 4, 5], [3, 4, 8, 9]]. % ``` tuples_in(Tuples, Relation) :- must_be(list(list), Tuples), maplist(maplist(fd_variable), Tuples), must_be(list(list(integer)), Relation), new_queue(Q0), phrase(tuples_relation(Tuples, Relation), [Q0], [Q]), append(Tuples, Vs), variables_same_queue(Vs), phrase(do_queue, [Q], _). tuples_relation([], _) --> []. tuples_relation([Tuple|Tuples], Relation) --> { relation_unifiable(Relation, Tuple, Us, _, _) }, ( ground(Tuple) -> { memberchk(Tuple, Relation) } ; tuple_domain(Tuple, Us), ( Tuple = [_,_|_] -> tuple_freeze(Tuple, Us) ; [] ) ), tuples_relation(Tuples, Relation). list_first_rest([L|Ls], L, Ls). tuple_domain([], _) --> []. tuple_domain([T|Ts], Relation0) --> { maplist(list_first_rest, Relation0, Firsts, Relation1) }, ( Firsts = [Unique] -> T = Unique ; ( var(T) -> { list_to_domain(Firsts, FDom), fd_get(T, TDom, TPs), domains_intersection(TDom, FDom, TDom1) }, fd_put(T, TDom1, TPs) ; [] ) ), tuple_domain(Ts, Relation1). tuple_freeze(Tuple, Relation) --> ( ground(Tuple) -> { memberchk(Tuple, Relation) } ; { put_attr(R, clpz_relation, Relation), make_propagator(rel_tuple(R, Tuple), Prop) }, tuple_freeze_(Tuple, Prop) ). tuple_freeze_([], _) --> []. tuple_freeze_([T|Ts], Prop) --> ( var(T) -> init_propagator_([T], Prop), trigger_prop(Prop) ; [] ), tuple_freeze_(Ts, Prop). relation_unifiable([], _, [], Changed, Changed). relation_unifiable([R|Rs], Tuple, Us, Changed0, Changed) :- ( all_in_domain(R, Tuple) -> Us = [R|Rest], relation_unifiable(Rs, Tuple, Rest, Changed0, Changed) ; relation_unifiable(Rs, Tuple, Us, true, Changed) ). all_in_domain([], []). all_in_domain([A|As], [T|Ts]) :- ( fd_get(T, Dom, _) -> domain_contains(Dom, A) ; T =:= A ), all_in_domain(As, Ts). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %run_propagator(P, _) --> { portray_clause(run_propagator(P)), false }. % trivial propagator, used only to remember pending constraints run_propagator(presidual(_), _) --> []. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pdifferent(Left,Right,X,_), MState) --> run_propagator(pexclude(Left,Right,X), MState). run_propagator(pexclude(Left,Right,X), _) --> ( ground(X) -> disable_queue, exclude_fire(Left, Right, X), enable_queue ; true ). run_propagator(pdistinct(Ls), _MState) --> distinct(Ls). run_propagator(pnvalue(N, Vars), _MState) --> { propagate_nvalue(N, Vars) }. run_propagator(check_distinct(Left,Right,X), _) --> { \+ list_contains(Left, X), \+ list_contains(Right, X) }. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pelement(N, Is, V), MState) --> ( { fd_get(N, NDom, _) } -> ( { fd_get(V, VDom, VPs) } -> { integers_remaining(Is, 1, NDom, empty, VDom1), domains_intersection(VDom, VDom1, VDom2) }, fd_put(V, VDom2, VPs) ; [] ) ; { kill(MState), nth1(N, Is, V) } ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pgcc_single(Vs, Pairs), _) --> gcc_global(Vs, Pairs). run_propagator(pgcc_check_single(Pairs), _) --> gcc_check(Pairs). run_propagator(pgcc_check(Pairs), _) --> gcc_check(Pairs). run_propagator(pgcc(Vs, _, Pairs), _) --> gcc_global(Vs, Pairs). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pcircuit(Vs), _MState) --> distinct(Vs), { propagate_circuit(Vs) }. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pgeq(A,B), MState) --> ( A == B -> kill(MState) ; nonvar(A) -> ( nonvar(B) -> kill(MState), A >= B ; { fd_get(B, BD, BPs), domain_remove_greater_than(BD, A, BD1) }, kill(MState), fd_put(B, BD1, BPs) ) ; nonvar(B) -> { fd_get(A, AD, APs), domain_remove_smaller_than(AD, B, AD1) }, kill(MState), fd_put(A, AD1, APs) ; { fd_get(A, AD, AL, AU, APs), fd_get(B, _, BL, BU, _), AU cis_geq BL }, ( { AL cis_geq BU } -> kill(MState) ; AU == BL -> kill(MState), A = B ; { NAL cis max(AL,BL), domains_intersection(AD, from_to(NAL,AU), NAD) }, fd_put(A, NAD, APs), ( { fd_get(B, BD2, BL2, BU2, BPs2) } -> { NBU cis min(BU2, AU), domains_intersection(BD2, from_to(BL2,NBU), NBD) }, fd_put(B, NBD, BPs2) ; [] ) ) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(rel_tuple(R, Tuple), MState) --> { get_attr(R, clpz_relation, Relation) }, ( { ground(Tuple) } -> kill(MState), { del_attr(R, clpz_relation), memberchk(Tuple, Relation) } ; { relation_unifiable(Relation, Tuple, Us, false, Changed), Us = [_|_] }, ( { Tuple = [First,Second], ( ground(First) ; ground(Second) ) } -> kill(MState) ; [] ), ( { Us = [Single] } -> kill(MState), { del_attr(R, clpz_relation) }, Single = Tuple ; { Changed } -> { put_attr(R, clpz_relation, Us) }, disable_queue, tuple_domain(Tuple, Us), enable_queue ; [] ) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pserialized(S_I, D_I, S_J, D_J, _), MState) --> ( nonvar(S_I), nonvar(S_J) -> kill(MState), ( S_I + D_I =< S_J -> [] ; S_J + D_J =< S_I -> [] ; false ) ; serialize_lower_upper(S_I, D_I, S_J, D_J, MState), serialize_lower_upper(S_J, D_J, S_I, D_I, MState) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % X #\= Y run_propagator(pneq(A, B), MState) --> ( nonvar(A) -> ( nonvar(B) -> A =\= B, kill(MState) ; { fd_get(B, BD0, BExp0), domain_remove(BD0, A, BD1), kill(MState) }, fd_put(B, BD1, BExp0) ) ; nonvar(B) -> run_propagator(pneq(B, A), MState) ; A \== B, { fd_get(A, _, AI, AS, _), fd_get(B, _, BI, BS, _) }, ( { AS cis_lt BI } -> kill(MState) ; { AI cis_gt BS } -> kill(MState) ; [] ) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Y = abs(X) run_propagator(pabs(X,Y), MState) --> ( nonvar(X) -> kill(MState), Y is abs(X) ; nonvar(Y) -> kill(MState), Y >= 0, YN is -Y, { X in YN \/ Y } ; X == Y -> kill(MState) ; { fd_get(X, XD, XPs), fd_get(Y, YD, _), domain_negate(YD, YDNegative), domains_union(YD, YDNegative, XD1), domains_intersection(XD, XD1, XD2) }, fd_put(X, XD2, XPs), ( { fd_get(Y, YD1, YPs1) } -> { domain_negate(XD2, XD2Neg), domains_union(XD2, XD2Neg, YD2), domain_remove_smaller_than(YD2, 0, YD3), domains_intersection(YD1, YD3, YD4) }, fd_put(Y, YD4, YPs1) ; [] ) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % abs(X-Y) #\= C run_propagator(absdiff_neq(X,Y,C), MState) --> ( C < 0 -> kill(MState) ; nonvar(X) -> kill(MState), ( nonvar(Y) -> abs(X - Y) =\= C ; V1 is X - C, neq_num(Y, V1), V2 is C + X, neq_num(Y, V2) ) ; nonvar(Y) -> kill(MState), V1 is C + Y, neq_num(X, V1), V2 is Y - C, neq_num(X, V2) ; [] ). % X #= abs(X) + V run_propagator(x_eq_abs_plus_v(X,V), MState) --> ( nonvar(V) -> ( V =:= 0 -> kill(MState), { X in 0..sup } ; V < 0 -> kill(MState), { X #= V / 2 } ; false % V > 0 ) ; nonvar(X) -> kill(MState), { V #= X - abs(X) } ; true ). % X #\= Y + Z run_propagator(x_neq_y_plus_z(X,Y,Z), MState) --> ( nonvar(X) -> ( nonvar(Y) -> ( nonvar(Z) -> kill(MState), X =\= Y + Z ; kill(MState), XY is X - Y, neq_num(Z, XY) ) ; nonvar(Z) -> kill(MState), XZ is X - Z, neq_num(Y, XZ) ; [] ) ; nonvar(Y) -> ( nonvar(Z) -> kill(MState), YZ is Y + Z, neq_num(X, YZ) ; Y =:= 0 -> kill(MState), { neq(X, Z) } ; [] ) ; Z == 0 -> kill(MState), { neq(X, Y) } ; true ). % X #=< Y + C run_propagator(x_leq_y_plus_c(X,Y,C), MState) --> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), X =< Y + C ; kill(MState), R is X - C, { fd_get(Y, YD, YPs), domain_remove_smaller_than(YD, R, YD1) }, fd_put(Y, YD1, YPs) ) ; nonvar(Y) -> kill(MState), R is Y + C, { fd_get(X, XD, XPs), domain_remove_greater_than(XD, R, XD1) }, fd_put(X, XD1, XPs) ; ( X == Y -> C >= 0, kill(MState) ; { fd_get(Y, YD, _) }, ( { domain_supremum(YD, n(YSup)) } -> YS1 is YSup + C, { fd_get(X, XD, XPs), domain_remove_greater_than(XD, YS1, XD1) }, fd_put(X, XD1, XPs) ; [] ), ( { fd_get(X, XD2, _), domain_infimum(XD2, n(XInf)) } -> XI1 is XInf - C, ( { fd_get(Y, YD1, YPs1) } -> { domain_remove_smaller_than(YD1, XI1, YD2), ( domain_infimum(YD2, n(YInf)), domain_supremum(XD2, n(XSup)), XSup =< YInf + C -> kill(MState) ; true ) }, fd_put(Y, YD2, YPs1) ; [] ) ; [] ) ) ). run_propagator(scalar_product_neq(Cs0,Vs0,P0), MState) --> { coeffs_variables_const(Cs0, Vs0, Cs, Vs, 0, I), P is P0 - I, ( Vs = [] -> kill(MState), P =\= 0 ; Vs = [V], Cs = [C] -> kill(MState), ( C =:= 1 -> neq_num(V, P) ; C*V #\= P ) ; Cs == [1,-1] -> kill(MState), Vs = [A,B], x_neq_y_plus_z(A, B, P) ; Cs == [-1,1] -> kill(MState), Vs = [A,B], x_neq_y_plus_z(B, A, P) ; P =:= 0, Cs = [1,1,-1] -> kill(MState), Vs = [A,B,C], x_neq_y_plus_z(C, A, B) ; P =:= 0, Cs = [1,-1,1] -> kill(MState), Vs = [A,B,C], x_neq_y_plus_z(B, A, C) ; P =:= 0, Cs = [-1,1,1] -> kill(MState), Vs = [A,B,C], x_neq_y_plus_z(A, B, C) ; true ) }. run_propagator(scalar_product_leq(Cs0,Vs0,P0), MState) --> { coeffs_variables_const(Cs0, Vs0, Cs, Vs, 0, I) }, P is P0 - I, ( Vs = [] -> kill(MState), P >= 0 ; { duophrase(sum_finite_domains(Cs, Vs, 0, 0, Inf, Sup), Infs, Sups) }, D1 is P - Inf, disable_queue, ( Infs == [], Sups == [] -> Inf =< P, ( Sup =< P -> kill(MState) ; remove_dist_upper_leq(Cs, Vs, D1) ) ; Infs == [] -> Inf =< P, remove_dist_upper(Sups, D1) ; Infs = [_] -> remove_upper(Infs, D1) ; true ), enable_queue ). run_propagator(scalar_product_eq(Cs0,Vs0,P0), MState) --> { coeffs_variables_const(Cs0, Vs0, Cs, Vs, 0, I) }, P is P0 - I, ( Vs = [] -> kill(MState), P =:= 0 ; Vs = [V], Cs = [C] -> kill(MState), P mod C =:= 0, V is P // C ; Cs == [1,1] -> kill(MState), Vs = [A,B], { A + B #= P } ; Cs == [1,-1] -> kill(MState), Vs = [A,B], { A #= P + B } ; Cs == [-1,1] -> kill(MState), Vs = [A,B], { B #= P + A } ; Cs == [-1,-1] -> kill(MState), Vs = [A,B], P1 is -P, { A + B #= P1 } ; P =:= 0, Cs == [1,1,-1] -> kill(MState), Vs = [A,B,C], { A + B #= C } ; P =:= 0, Cs == [1,-1,1] -> kill(MState), Vs = [A,B,C], { A + C #= B } ; P =:= 0, Cs == [-1,1,1] -> kill(MState), Vs = [A,B,C], { B + C #= A } ; { duophrase(sum_finite_domains(Cs, Vs, 0, 0, Inf, Sup), Infs, Sups) }, % { nl, writeln(Infs-Sups-Inf-Sup) }, D1 is P - Inf, D2 is Sup - P, disable_queue, ( Infs == [], Sups == [] -> { between(Inf, Sup, P) }, remove_dist_upper_lower(Cs, Vs, D1, D2) ; Sups = [] -> P =< Sup, remove_dist_lower(Infs, D2) ; Infs = [] -> Inf =< P, remove_dist_upper(Sups, D1) ; Sups = [_], Infs = [_] -> remove_lower(Sups, D2), remove_upper(Infs, D1) ; Infs = [_] -> remove_upper(Infs, D1) ; Sups = [_] -> remove_lower(Sups, D2) ; true ), enable_queue ). % X + Y = Z run_propagator(pplus(X,Y,Z,Morph), MState) --> ( nonvar(X) -> ( X =:= 0 -> kill(MState), Y = Z ; Y == Z -> kill(MState), X =:= 0 ; nonvar(Y) -> kill(MState), Z is X + Y ; nonvar(Z) -> kill(MState), Y is Z - X ; { fd_get(Z, ZD, ZPs), fd_get(Y, YD, _), domain_shift(YD, X, Shifted_YD), domains_intersection(ZD, Shifted_YD, ZD1) }, fd_put(Z, ZD1, ZPs), ( { fd_get(Y, YD1, YPs) } -> O is -X, { domain_shift(ZD1, O, YD2), domains_intersection(YD1, YD2, YD3) }, fd_put(Y, YD3, YPs) ; [] ) ) ; nonvar(Y) -> run_propagator(pplus(Y,X,Z,Morph), MState) ; nonvar(Z) -> ( X == Y -> kill(MState), { even(Z), X is Z // 2 } ; { fd_get(X, XD, _), fd_get(Y, YD, YPs), domain_negate(XD, XDN), domain_shift(XDN, Z, YD1), domains_intersection(YD, YD1, YD2) }, fd_put(Y, YD2, YPs), ( { fd_get(X, XD1, XPs) } -> { domain_negate(YD2, YD2N), domain_shift(YD2N, Z, XD2), domains_intersection(XD1, XD2, XD3) }, fd_put(X, XD3, XPs) ; [] ) ) ; ( X == Y -> morph_into_propagator(MState, [X,Z], ptimes(2,X,Z), Morph) ; X == Z -> kill(MState), Y = 0 ; Y == Z -> kill(MState), X = 0 ; { fd_get(X, XD, XL, XU, XPs), fd_get(Y, _, YL, YU, _), fd_get(Z, _, ZL, ZU, _), NXL cis max(XL, ZL-YU), NXU cis min(XU, ZU-YL) }, update_bounds(X, XD, XPs, XL, XU, NXL, NXU), ( { fd_get(Y, YD2, YL2, YU2, YPs2) } -> { NYL cis max(YL2, ZL-NXU), NYU cis min(YU2, ZU-NXL) }, update_bounds(Y, YD2, YPs2, YL2, YU2, NYL, NYU) ; NYL = n(Y), NYU = n(Y) ), ( { fd_get(Z, ZD2, ZL2, ZU2, ZPs2) } -> { NZL cis max(ZL2,NXL+NYL), NZU cis min(ZU2,NXU+NYU) }, update_bounds(Z, ZD2, ZPs2, ZL2, ZU2, NZL, NZU) ; [] ) ) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(ptimes(X,Y,Z,Morph), MState) --> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), Z is X * Y ; X =:= 0 -> kill(MState), Z = 0 ; X =:= 1 -> kill(MState), Z = Y ; nonvar(Z) -> kill(MState), 0 =:= Z mod X, Y is Z // X ; ( Y == Z -> kill(MState), Y = 0 ; { fd_get(Y, YD, _), fd_get(Z, ZD, ZPs), domain_expand(YD, X, Scaled_YD), domains_intersection(ZD, Scaled_YD, ZD1) }, fd_put(Z, ZD1, ZPs), ( { fd_get(Y, YDom2, YPs2) } -> { domain_contract(ZD1, X, Contract), domains_intersection(YDom2, Contract, NYDom) }, fd_put(Y, NYDom, YPs2) ; kill(MState), Z is X * Y ) ) ) ; nonvar(Y) -> run_propagator(ptimes(Y,X,Z,Morph), MState) ; nonvar(Z) -> ( X == Y -> kill(MState), { integer_kth_root(Z, 2, R), NR is -R, X in NR \/ R } ; { fd_get(X, XD, XL, XU, XPs), fd_get(Y, YD, YL, YU, _), min_max_factor(n(Z), n(Z), YL, YU, XL, XU, NXL, NXU) }, update_bounds(X, XD, XPs, XL, XU, NXL, NXU), ( { fd_get(Y, YD2, YL2, YU2, YPs2) } -> { min_max_factor(n(Z), n(Z), NXL, NXU, YL2, YU2, NYL, NYU) }, update_bounds(Y, YD2, YPs2, YL2, YU2, NYL, NYU) ; ( Y =\= 0 -> 0 =:= Z mod Y, kill(MState), X is Z // Y ; kill(MState), Z = 0 ) ), ( Z =:= 0 -> ( { \+ domain_contains(XD, 0) } -> kill(MState), Y = 0 ; { \+ domain_contains(YD, 0) } -> kill(MState), X = 0 ; [] ) ; neq_num(X, 0), neq_num(Y, 0) ) ) ; ( X == Y -> morph_into_propagator(MState, [X,Z], pexp(X,2,Z), Morph) ; { fd_get(X, XD, XL, XU, XPs), fd_get(Y, _, YL, YU, _), fd_get(Z, ZD, ZL, ZU, _) }, ( { Y == Z, \+ domain_contains(ZD, 0) } -> kill(MState), X = 1 ; { X == Z, \+ domain_contains(ZD, 0) } -> kill(MState), Y = 1 ; { min_max_factor(ZL, ZU, YL, YU, XL, XU, NXL, NXU) }, update_bounds(X, XD, XPs, XL, XU, NXL, NXU), ( { fd_get(Y, YD2, YL2, YU2, YPs2) } -> { min_max_factor(ZL, ZU, NXL, NXU, YL2, YU2, NYL, NYU) }, update_bounds(Y, YD2, YPs2, YL2, YU2, NYL, NYU) ; NYL = n(Y), NYU = n(Y) ), ( { fd_get(Z, ZD2, ZL2, ZU2, ZPs2) } -> { min_product(NXL, NXU, NYL, NYU, NZL), max_product(NXL, NXU, NYL, NYU, NZU) }, ( { NZL cis_leq ZL2, NZU cis_geq ZU2 } -> ZD3 = ZD2 ; { domains_intersection(ZD2, from_to(NZL,NZU), ZD3) }, fd_put(Z, ZD3, ZPs2) ), ( { domain_contains(ZD3, 0) } -> [] ; neq_num(X, 0), neq_num(Y, 0) ) ; [] ) ) ) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % X // Y = Z (round towards zero) run_propagator(ptzdiv(X,Y,Z,Morph), MState) --> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), Y =\= 0, Z is X // Y ; { fd_get(Y, YD, YL, YU, YPs) }, ( nonvar(Z) -> ( Z =:= 0 -> NYL is -abs(X) - 1, NYU is abs(X) + 1, { domains_intersection(YD, split(0, from_to(inf,n(NYL)), from_to(n(NYU), sup)), NYD) }, fd_put(Y, NYD, YPs) ; ( sign(X) =:= sign(Z) -> { NYL cis max(n(X) // (n(Z)+sign(n(Z))) + n(1), YL), NYU cis min(n(X) // n(Z), YU) } ; { NYL cis max(n(X) // n(Z), YL), NYU cis min(n(X) // (n(Z)+sign(n(Z))) - n(1), YU) } ), update_bounds(Y, YD, YPs, YL, YU, NYL, NYU) ) ; { fd_get(Z, ZD, ZL, ZU, ZPs), ( X >= 0, ( YL cis_gt n(0) ; YU cis_lt n(0) )-> NZL cis max(n(X)//YU, ZL), NZU cis min(n(X)//YL, ZU) ; X < 0, ( YL cis_gt n(0) ; YU cis_lt n(0) ) -> NZL cis max(n(X)//YL, ZL), NZU cis min(n(X)//YU, ZU) ; % TODO: more stringent bounds, cover Y NZL cis max(-abs(n(X)), ZL), NZU cis min(abs(n(X)), ZU) ) }, update_bounds(Z, ZD, ZPs, ZL, ZU, NZL, NZU), ( { X >= 0, NZL cis_gt n(0), fd_get(Y, YD1, YPs1) } -> { NYL cis n(X) // (NZU + n(1)) + n(1), NYU cis n(X) // NZL, domains_intersection(YD1, from_to(NYL, NYU), NYD1) }, fd_put(Y, NYD1, YPs1) ; true ) ) ) ; nonvar(Y) -> Y =\= 0, ( Y =:= 1 -> kill(MState), X = Z ; Y =:= -1 -> morph_into_propagator(MState, [X,Z], pplus(X,Z,0), Morph) ; { fd_get(X, XD, XL, XU, XPs) }, ( nonvar(Z) -> kill(MState), ( sign(Z) =:= sign(Y) -> { NXL cis max(n(Z)*n(Y), XL), NXU cis min((abs(n(Z))+n(1))*abs(n(Y))-n(1), XU) } ; Z =:= 0 -> { NXL cis max(-abs(n(Y)) + n(1), XL), NXU cis min(abs(n(Y)) - n(1), XU) } ; { NXL cis max((n(Z)+sign(n(Z)))*n(Y)+n(1), XL), NXU cis min(n(Z)*n(Y), XU) } ), update_bounds(X, XD, XPs, XL, XU, NXL, NXU) ; { fd_get(Z, ZD, ZPs), domain_contract_less(XD, Y, Contracted), domains_intersection(ZD, Contracted, NZD) }, fd_put(Z, NZD, ZPs), ( { fd_get(X, XD2, XPs2) } -> { domain_expand_more(NZD, Y, Expanded), domains_intersection(XD2, Expanded, NXD2) }, fd_put(X, NXD2, XPs2) ; true ) ) ) ; nonvar(Z) -> { fd_get(X, XD, XL, XU, XPs), fd_get(Y, _, YL, YU, _), ( YL cis_geq n(0), XL cis_geq n(0) -> NXL cis max(YL*n(Z), XL), NXU cis min(YU*(n(Z)+n(1))-n(1), XU) ; %TODO: cover more cases NXL = XL, NXU = XU ) }, update_bounds(X, XD, XPs, XL, XU, NXL, NXU) ; ( X == Y -> kill(MState), Z = 1 ; { fd_get(X, _, XL, XU, _), fd_get(Y, _, YL, _, _), fd_get(Z, ZD, ZPs), NZU cis max(abs(XL), XU), NZL cis -NZU, domains_intersection(ZD, from_to(NZL,NZU), NZD0), ( XL cis_geq n(0), YL cis_geq n(0) -> domain_remove_smaller_than(NZD0, 0, NZD1) ; % TODO: cover more cases NZD1 = NZD0 ) }, fd_put(Z, NZD1, ZPs) ) ). %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Z = X mod Y run_propagator(pmod(X,Y,Z), MState) --> ( Y == 0 -> false ; Y == Z -> false ; X == Y -> kill(MState), queue_goal(Z = 0) ; true ), ( nonvar(X), nonvar(Y) -> kill(MState), Z is X mod Y ; nonvar(Y), nonvar(Z) -> ( Y > 0 -> Z >= 0, Z < Y ; Z =< 0, Z > Y % Y < 0 ), ( { fd_get(X, _, n(XL), _, _) } -> ( (XL - Z) mod Y =\= 0 -> XMin is Z + Y * ((XL - Z) div Y + 1) ; XMin is XL ), { fd_get(X, XD0, XPs), domain_remove_smaller_than(XD0, XMin, XD2) }, fd_put(X, XD2, XPs) % queue_goal(X #>= XMin) ; true ), ( { fd_get(X, _, _, n(XU), _) } -> XMax is Z + Y * ((XU - Z) div Y), { fd_get(X, XD1, XPs), domain_remove_greater_than(XD1, XMax, XD3) }, fd_put(X, XD3, XPs) % queue_goal(X #=< XMax) ; true ) ; nonvar(Z), nonvar(X) -> ( Z > 0 -> ( X < 0 -> true ; X >= Z ) ; Z < 0 -> ( X > 0 -> true ; X =< Z ) ; Z =:= 0 % Multiple solutions so do nothing special. ), ( { fd_get(Y, _, _, n(YU), _), YU < X, X =< 0 } -> kill(MState), Z =:= X ; { fd_get(Y, _, n(YL), _, _), YL > X, X >= 0 } -> kill(MState), Z =:= X ; ( Z > 0 -> { fd_get(Y, YD, YPs), YMin is Z + 1, domain_remove_smaller_than(YD, YMin, YD1) }, fd_put(Y, YD1, YPs) % queue_goal(Y #> Z) ; Z < 0 -> { fd_get(Y, YD, YPs), YMax is Z - 1, domain_remove_greater_than(YD, YMax, YD1) }, fd_put(Y, YD1, YPs) % queue_goal(Y #< Z) ; true ) ) ; run_propagator(pmodz(X,Y,Z), MState), run_propagator(pmody(X,Y,Z), MState), true ). run_propagator(pmodz(X,Y,Z), MState) --> ( nonvar(Z) -> true % Nothing to do. ; nonvar(X) -> ( X =:= 0 -> kill(MState), queue_goal(Z = X) ; ( X > 0 -> ( { fd_get(Y, _, n(YL), _, _), YL > X } -> kill(MState), queue_goal(Z = X) ; { fd_get(Z, ZD0, ZPs), domain_remove_greater_than(ZD0, X, ZD2) }, fd_put(Z, ZD2, ZPs) % queue_goal(Z #=< X) ) ; X < 0, ( { fd_get(Y, _, _, n(YU), _), YU < X } -> kill(MState), queue_goal(Z = X) ; { fd_get(Z, ZD0, ZPs), domain_remove_smaller_than(ZD0, X, ZD2) }, fd_put(Z, ZD2, ZPs) % queue_goal(Z #>= X) ) ), ( { fd_get(Y, _, n(YL), n(YU), _), YL > 0 } -> ZMax is YU - 1, { fd_get(Z, ZD1, ZPs), domain_remove_smaller_than(ZD1, 0, ZD3), domain_remove_greater_than(ZD3, ZMax, ZD5) }, fd_put(Z, ZD5, ZPs) % queue_goal(Z in 0..ZMax) ; { fd_get(Y, _, n(YL), n(YU), _), YU < 0 } -> ZMin is YL + 1, { fd_get(Z, ZD1, ZPs), domain_remove_greater_than(ZD1, 0, ZD3), domain_remove_smaller_than(ZD3, ZMin, ZD5) }, fd_put(Z, ZD5, ZPs) % queue_goal(Z in ZMin..0) ; true ) ) ; nonvar(Y) -> ( abs(Y) =:= 1 -> kill(MState), queue_goal(Z = 0) ; Y < 0 -> ( { fd_get(X, _, n(XL), n(XU), _), XU =< 0, Y < XL } -> kill(MState), queue_goal(Z = X) ; ZMin is Y + 1, { fd_get(Z, ZD1, ZPs), domain_remove_greater_than(ZD1, 0, ZD3), domain_remove_smaller_than(ZD3, ZMin, ZD5) }, fd_put(Z, ZD5, ZPs) % queue_goal(Z in ZMin..0) ) ; Y > 0, ( { fd_get(X, _, n(XL), n(XU), _), XL >= 0, Y > XU } -> kill(MState), queue_goal(Z = X) ; ZMax is Y - 1, { fd_get(Z, ZD1, ZPs), domain_remove_smaller_than(ZD1, 0, ZD3), domain_remove_greater_than(ZD3, ZMax, ZD5) }, fd_put(Z, ZD5, ZPs) % queue_goal(Z in 0..ZMax) ) ) ; ( { fd_get(X, _, n(XL), n(XU), _), XL >= 0, fd_get(Y, _, n(YL), _, _), XU < YL } -> kill(MState), queue_goal(Z = X) ; { fd_get(X, _, n(XL), n(XU), _), XU =< 0, fd_get(Y, _, _, n(YU), _), XL > YU } -> kill(MState), queue_goal(Z = X) ; ( { fd_get(X, _, n(XL), n(XU), _), XL >= 0 } -> { fd_get(Z, ZD0, ZPs), domain_remove_greater_than(ZD0, XU, ZD2) }, fd_put(Z, ZD2, ZPs) % queue_goal(Z #=< XU) ; { fd_get(X, _, n(XL), n(XU), _), XU =< 0 } -> { fd_get(Z, ZD0, ZPs), domain_remove_smaller_than(ZD0, XL, ZD2) }, fd_put(Z, ZD2, ZPs) % queue_goal(Z #>= XL) ; true ), ( { fd_get(Y, _, n(YL), n(YU), _), YL > 0 } -> ZMax is YU - 1, { fd_get(Z, ZD1, ZPs), domain_remove_smaller_than(ZD1, 0, ZD3), domain_remove_greater_than(ZD3, ZMax, ZD5) }, fd_put(Z, ZD5, ZPs) % queue_goal(Z in 0..ZMax) ; { fd_get(Y, _, n(YL), n(YU), _), YU < 0 } -> ZMin is YL + 1, { fd_get(Z, ZD1, ZPs), domain_remove_greater_than(ZD1, 0, ZD3), domain_remove_smaller_than(ZD3, ZMin, ZD5) }, fd_put(Z, ZD5, ZPs) % queue_goal(Z in ZMin..0) ; { fd_get(Y, _, n(YL), n(YU), _), YL < 0, YU > 0 } -> ZMin is YL + 1, ZMax is YU - 1, { fd_get(Z, ZD1, ZPs), domain_remove_greater_than(ZD1, ZMax, ZD3), domain_remove_smaller_than(ZD3, ZMin, ZD5) }, fd_put(Z, ZD5, ZPs) % queue_goal(Z in ZMin..ZMax) ; { fd_get(Y, _, _, n(YU), _), YU > 0 } -> { fd_get(Z, ZD1, ZPs), ZMax is YU - 1, domain_remove_greater_than(ZD1, ZMax, ZD3) }, fd_put(Z, ZD3, ZPs) % queue_goal(Z #< YU) ; { fd_get(Y, _, n(YL), _, _), YL < 0 } -> { fd_get(Z, ZD1, ZPs), ZMin is YL + 1, domain_remove_smaller_than(ZD1, ZMin, ZD3) }, fd_put(Z, ZD3, ZPs) % queue_goal(Z #> YL) ; true ) ) ). run_propagator(pmody(_X,Y,Z), _MState) --> ( nonvar(Y) -> true % Nothing to do. % ; nonvar(X) -> true ; nonvar(Z) -> ( Z > 0 -> { fd_get(Y, YD, YPs), YMin is Z + 1, domain_remove_smaller_than(YD, YMin, YD1) }, fd_put(Y, YD1, YPs) % queue_goal(Y #> Z) ; Z < 0 -> { fd_get(Y, YD, YPs), YMax is Z - 1, domain_remove_greater_than(YD, YMax, YD1) }, fd_put(Y, YD1, YPs) % queue_goal(Y #< Z) ; Z =:= 0 % Multiple solutions so do nothing special. ) ; ( { fd_get(Z, _, n(ZL), _, _), ZL > 0 } -> { fd_get(Y, YD, YPs), YMin is ZL + 1, domain_remove_smaller_than(YD, YMin, YD1) }, fd_put(Y, YD1, YPs) % queue_goal(Y #> ZL) ; { fd_get(Z, _, _, n(ZU), _), ZU < 0 } -> { fd_get(Y, YD, YPs), YMax is ZU - 1, domain_remove_greater_than(YD, YMax, YD1) }, fd_put(Y, YD1, YPs) % queue_goal(Y #< ZU) ; true ) ). %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Z = X rem Y run_propagator(prem(X,Y,Z), MState) --> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), Y =\= 0, Z is X rem Y ; U is abs(X), { fd_get(Y, YD, _) }, ( X >=0, { domain_infimum(YD, n(Min)), Min >= 0 } -> L = 0 ; L is -U ), { Z in L..U } ) ; nonvar(Y) -> Y =\= 0, ( abs(Y) =:= 1 -> kill(MState), Z = 0 ; var(Z) -> YP is abs(Y) - 1, YN is -YP, ( Y > 0, { fd_get(X, _, n(XL), n(XU), _) } -> ( abs(XL) < Y, XU < Y -> kill(MState), Z = X, ZL = XL ; XL < 0, abs(XL) < Y -> ZL = XL ; XL >= 0 -> ZL = 0 ; ZL = YN ), ( XU > 0, XU < Y -> ZU = XU ; XU < 0 -> ZU = 0 ; ZU = YP ) ; ZL = YN, ZU = YP ), ( { fd_get(Z, ZD, ZPs) } -> { domains_intersection(ZD, from_to(n(ZL), n(ZU)), ZD1) }, fd_put(Z, ZD1, ZPs) ; ZD1 = from_to(n(Z), n(Z)) ), ( { fd_get(X, XD, _), domain_infimum(XD, n(Min)) } -> Z1 is Min rem Y, ( { domain_contains(ZD1, Z1) } -> true ; neq_num(X, Min) ) ; true ), ( { fd_get(X, XD1, _), domain_supremum(XD1, n(Max)) } -> Z2 is Max rem Y, ( { domain_contains(ZD1, Z2) } -> true ; neq_num(X, Max) ) ; true ) ; { fd_get(X, XD1, XPs1) }, % if possible, propagate at the boundaries ( { domain_infimum(XD1, n(Min)) } -> ( Min rem Y =:= Z -> true ; Y > 0, Min > 0 -> Next is ((Min - Z + Y - 1) div Y)*Y + Z, { domain_remove_smaller_than(XD1, Next, XD2) }, fd_put(X, XD2, XPs1) ; % TODO: bigger steps in other cases as well neq_num(X, Min) ) ; true ), ( { fd_get(X, XD3, XPs3) } -> ( { domain_supremum(XD3, n(Max)) } -> ( Max rem Y =:= Z -> true ; Y > 0, Max > 0 -> Prev is ((Max - Z) div Y)*Y + Z, { domain_remove_greater_than(XD3, Prev, XD4) }, fd_put(X, XD4, XPs3) ; % TODO: bigger steps in other cases as well neq_num(X, Max) ) ; true ) ; true ) ) ; X == Y -> kill(MState), Z = 0 ; { fd_get(Z, ZD, ZPs) } -> { fd_get(Y, _, YInf, YSup, _), fd_get(X, _, XInf, XSup, _), M cis max(abs(YInf),YSup), ( XInf cis_geq n(0) -> Inf0 = n(0) ; Inf0 = XInf ), ( XSup cis_leq n(0) -> Sup0 = n(0) ; Sup0 = XSup ), NInf cis max(max(Inf0, -M + n(1)), min(XInf,-XSup)), NSup cis min(min(Sup0, M - n(1)), max(abs(XInf),XSup)), domains_intersection(ZD, from_to(NInf,NSup), ZD1) }, fd_put(Z, ZD1, ZPs) ; true % TODO: propagate more ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Z = max(X,Y) run_propagator(pmax(X,Y,Z), MState) --> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), queue_goal(Z is max(X,Y)) ; nonvar(Z) -> ( Z =:= X -> kill(MState), queue_goal(X #>= Y) ; Z > X -> queue_goal(Z = Y) ; false % Z < X ) ; Y == Z -> kill(MState), queue_goal(Y #>= X) ; { fd_get(Y, _, YInf, YSup, _) }, ( { YInf cis_gt n(X) } -> queue_goal(Z = Y) ; { YSup cis_lt n(X) } -> queue_goal(Z = X) ; YSup = n(M) -> { fd_get(Z, ZD, ZPs), domain_remove_greater_than(ZD, M, ZD1) }, fd_put(Z, ZD1, ZPs) ; [] ) ) ; nonvar(Y) -> run_propagator(pmax(Y,X,Z), MState) ; { fd_get(Z, ZD, ZPs) } -> { fd_get(X, _, XInf, XSup, _), fd_get(Y, _, YInf, YSup, _) }, ( { YInf cis_gt XSup } -> kill(MState), queue_goal(Z = Y) ; { YSup cis_lt XInf } -> kill(MState), queue_goal(Z = X) ; { n(M) cis max(XSup, YSup) } -> { domain_remove_greater_than(ZD, M, ZD1) }, fd_put(Z, ZD1, ZPs) ; [] ) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Z = min(X,Y) run_propagator(pmin(X,Y,Z), MState) --> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), Z is min(X,Y) ; nonvar(Z) -> ( Z =:= X -> kill(MState), { X #=< Y } ; Z < X -> Z = Y ; false % Z > X ) ; Y == Z -> kill(MState), queue_goal(Y #=< X) ; { fd_get(Y, _, YInf, YSup, _) }, ( { YSup cis_lt n(X) } -> Z = Y ; { YInf cis_gt n(X) } -> Z = X ; YInf = n(M) -> { fd_get(Z, ZD, ZPs), domain_remove_smaller_than(ZD, M, ZD1) }, fd_put(Z, ZD1, ZPs) ; [] ) ) ; nonvar(Y) -> run_propagator(pmin(Y,X,Z), MState) ; { fd_get(Z, ZD, ZPs) } -> { fd_get(X, _, XInf, XSup, _), fd_get(Y, _, YInf, YSup, _) }, ( { YSup cis_lt XInf } -> kill(MState), Z = Y ; { YInf cis_gt XSup } -> kill(MState), Z = X ; { n(M) cis min(XInf, YInf) } -> { domain_remove_smaller_than(ZD, M, ZD1) }, fd_put(Z, ZD1, ZPs) ; [] ) ; [] ). %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Z = X ^ Y run_propagator(pexp(X,Y,Z,Morph), MState) --> ( X == 1 -> kill(MState), Z = 1 ; X == 0 -> queue_goal((Z in 0..1, Y #>= 0)), morph_into_propagator(MState, [Y,Z], reified_eq(1,Y,1,0,[],Z), Morph) ; Y == 0 -> kill(MState), Z = 1 ; Y == 1 -> kill(MState), Z = X ; Y == Z -> kill(MState), X = Y, queue_goal(X in -1\/1) ; nonvar(X) -> ( nonvar(Y) -> ( Y >= 0 -> true ; X =:= -1 ), kill(MState), Z is X^Y ; nonvar(Z) -> ( Z > 1 -> abs(X) > 1, kill(MState), { integer_log_b(Z, X, 1, Y) } ; true ) ; { fd_get(Y, _, YL, YU, _), fd_get(Z, ZD, ZPs) }, ( { X > 0, YL cis_geq n(0) } -> { NZL cis n(X)^YL, NZU cis n(X)^YU, domains_intersection(ZD, from_to(NZL,NZU), NZD) }, fd_put(Z, NZD, ZPs) ; true ), ( { X > 0, fd_get(Z, _, _, n(ZMax), _), ZMax > 0 } -> { floor_integer_log_b(ZMax, X, 1, YCeil) }, queue_goal(Y in inf..YCeil) ; true ) ) ; nonvar(Z) -> ( nonvar(Y) -> { integer_kth_root(Z, Y, R) }, kill(MState), ( { even(Y) } -> N is -R, { X in N \/ R } ; X = R ) ; { fd_get(X, _, n(NXL), _, _), NXL > 1 } -> ( { Z > 1, between(NXL, Z, Exp), NXL^Exp > Z } -> Exp1 is Exp - 1, { fd_get(Y, YD, YPs), domains_intersection(YD, from_to(n(1),n(Exp1)), YD1) }, fd_put(Y, YD1, YPs), ( { fd_get(X, XD, XPs) } -> { domain_infimum(YD1, n(YL)), integer_kth_root_leq(Z, YL, RU), domains_intersection(XD, from_to(n(NXL),n(RU)), XD1) }, fd_put(X, XD1, XPs) ; true ) ; true ) ; true ) ; nonvar(Y), Y > 0 -> ( { even(Y) } -> { fd_get(Z, ZD0, ZPs0), domain_remove_smaller_than(ZD0, 0, ZDG0) }, fd_put(Z, ZDG0, ZPs0) ; true ), ( { fd_get(X, XD, XL, XU, _), fd_get(Z, ZD, ZL, ZU, ZPs) } -> ( { domain_contains(ZD, 0) } -> XD1 = XD ; { domain_remove(XD, 0, XD1) } ), ( { domain_contains(XD, 0) } -> ZD1 = ZD ; { domain_remove(ZD, 0, ZD1) } ), ( { even(Y) } -> ( { XL cis_geq n(0) } -> { NZL cis XL^n(Y) } ; { XU cis_leq n(0) } -> { NZL cis XU^n(Y) } ; NZL = n(0) ), { NZU cis max(abs(XL),abs(XU))^n(Y), domains_intersection(ZD1, from_to(NZL,NZU), ZD2) } ; ( { finite(XL) } -> { NZL cis XL^n(Y), NZU cis XU^n(Y) }, { domains_intersection(ZD1, from_to(NZL,NZU), ZD2) } ; ZD2 = ZD1 ) ), fd_put(Z, ZD2, ZPs), { ( even(Y), ZU = n(Num) -> integer_kth_root_leq(Num, Y, RU), ( XL cis_geq n(0), ZL = n(Num1), Num1 >= 0 -> integer_kth_root_leq(Num1, Y, RL0), ( RL0^Y < Num1 -> RL is RL0 + 1 ; RL = RL0 ) ; RL is -RU ), RL =< RU, NXD = from_to(n(RL),n(RU)) ; odd(Y), ZL cis_geq n(0), ZU = n(Num) -> integer_kth_root_leq(Num, Y, RU), ZL = n(Num1), integer_kth_root_leq(Num1, Y, RL0), ( RL0^Y < Num1 -> RL is RL0 + 1 ; RL = RL0 ), RL =< RU, NXD = from_to(n(RL),n(RU)) ; NXD = XD1 % TODO: propagate more ) }, ( { fd_get(X, XD2, XPs) } -> { domains_intersection(XD2, XD1, XD3), domains_intersection(XD3, NXD, XD4) }, fd_put(X, XD4, XPs) ; true ) ; true ) ; { fd_get(X, _, XL, _, _), XL cis_gt n(0), fd_get(Y, _, YL, _, _), YL cis_gt n(0), fd_get(Z, ZD, ZPs) } -> { n(NZL) cis XL^YL, domain_remove_smaller_than(ZD, NZL, ZD1) }, fd_put(Z, ZD1, ZPs) ; true ). %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Y = sign(X) run_propagator(psign(X,Y), MState) --> ( nonvar(X) -> kill(MState), queue_goal(Y is sign(X)) ; Y == -1 -> kill(MState), queue_goal(X #< 0) ; Y == 0 -> kill(MState), queue_goal(X = 0) ; Y == 1 -> kill(MState), queue_goal(X #> 0) ; { fd_get(X, _, XL, XU, _) }, ( { XL = n(L), L > 0 } -> kill(MState), queue_goal(Y = 1) ; { XU = n(U), U < 0 } -> kill(MState), queue_goal(Y = -1) ; true ) ). %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Y = popcount(X) run_propagator(ppopcount(X,Y), MState) --> ( nonvar(X) -> kill(MState), queue_goal(popcount(X, Y)) ; true ). %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Z = X xor Y run_propagator(pxor(X,Y,Z), MState) --> ( nonvar(X), nonvar(Y) -> kill(MState), Z is xor(X, Y) ; nonvar(Y), nonvar(Z) -> kill(MState), X is xor(Y, Z) ; nonvar(Z), nonvar(X) -> kill(MState), Y is xor(Z, X) ; X == Y -> kill(MState), queue_goal(Z = 0) ; Y == Z -> kill(MState), queue_goal(X = 0) ; Z == X -> kill(MState), queue_goal(Y = 0) ; X == 0 -> kill(MState), queue_goal(Y = Z) ; Y == 0 -> kill(MState), queue_goal(Z = X) ; Z == 0 -> kill(MState), queue_goal(X = Y) ; true ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pzcompare(Order, A, B), MState) --> ( A == B -> kill(MState), Order = (=) ; ( nonvar(A) -> ( nonvar(B) -> kill(MState), ( A > B -> Order = (>) ; Order = (<) ) ; { fd_get(B, _, BL, BU, _) }, ( { BL cis_gt n(A) } -> kill(MState), Order = (<) ; { BU cis_lt n(A) } -> kill(MState), Order = (>) ; [] ) ) ; nonvar(B) -> { fd_get(A, _, AL, AU, _) }, ( { AL cis_gt n(B) } -> kill(MState), Order = (>) ; { AU cis_lt n(B) } -> kill(MState), Order = (<) ; [] ) ; { fd_get(A, _, AL, AU, _), fd_get(B, _, BL, BU, _) }, ( { AL cis_gt BU } -> kill(MState), Order = (>) ; { AU cis_lt BL } -> kill(MState), Order = (<) ; [] ) ) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % reified constraints %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(reified_in(V,Dom,B), MState) --> ( integer(V) -> kill(MState), ( { domain_contains(Dom, V) } -> B = 1 ; B = 0 ) ; B == 1 -> kill(MState), { domain(V, Dom) } ; B == 0 -> kill(MState), { domain_complement(Dom, C), domain(V, C) } ; { fd_get(V, VD, _) }, ( { domains_intersection(VD, Dom, I) } -> ( I == VD -> kill(MState), B = 1 ; [] ) ; kill(MState), B = 0 ) ). run_propagator(reified_tuple_in(Tuple, R, B), MState) --> { get_attr(R, clpz_relation, Relation) }, ( B == 1 -> kill(MState), { tuples_in([Tuple], Relation) } ; ( ground(Tuple) -> kill(MState), ( { memberchk(Tuple, Relation) } -> B = 1 ; B = 0 ) ; { relation_unifiable(Relation, Tuple, Us, _, _) }, ( Us = [] -> kill(MState), B = 0 ; [] ) ) ). run_propagator(tuples_not_in(Tuples, Relation, B), MState) --> ( B == 0 -> kill(MState), { tuples_in_conjunction(Tuples, Relation, Conj), #\ Conj } ; [] ). run_propagator(kill_reified_tuples(B, Ps, Bs), _) --> ( B == 0 -> { maplist(kill_entailed, Ps), phrase(as(Bs), As), maplist(kill_entailed, As) } ; [] ). run_propagator(reified_fd(V,B), MState) --> ( { fd_inf(V, I), I \== inf, fd_sup(V, S), S \== sup } -> kill(MState), B = 1 ; { B == 0 } -> ( { fd_inf(V, inf) } -> [] ; { fd_sup(V, sup) } ) ; [] ). % The result of X/Y, X mod Y, and X rem Y is undefined iff Y is 0. run_propagator(pskeleton(X,Y,D,Skel,Z,_), MState) --> ( Y == 0 -> kill(MState), D = 0 ; D == 1 -> kill(MState), neq_num(Y, 0), { skeleton([X,Y,Z], Skel) } ; integer(Y), Y =\= 0 -> kill(MState), D = 1, { skeleton([X,Y,Z], Skel) } ; { fd_get(Y, YD, _), \+ domain_contains(YD, 0) } -> kill(MState), D = 1, { skeleton([X,Y,Z], Skel) } ; [] ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Propagators for arithmetic functions that only propagate functionally. These are currently the bitwise operations. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ run_propagator(pfunction(Op,A,B,R), MState) --> ( integer(A), integer(B) -> kill(MState), Expr =.. [Op,A,B], R is Expr ; [] ). run_propagator(pfunction(Op,A,R), MState) --> ( integer(A) -> kill(MState), ( Op == msb -> { msb(A, R) } ; Op == lsb -> { lsb(A, R) } ; Expr =.. [Op,A], R is Expr ) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(reified_geq(DX,X,DY,Y,Ps,B), MState) --> ( DX == 0 -> kill(MState, Ps), B = 0 ; DY == 0 -> kill(MState, Ps), B = 0 ; B == 1 -> kill(MState), DX = 1, DY = 1, { geq(X, Y) } ; DX == 1, DY == 1 -> ( var(B) -> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), ( X >= Y -> B = 1 ; B = 0 ) ; { fd_get(Y, _, YL, YU, _) }, ( { n(X) cis_geq YU } -> kill(MState, Ps), B = 1 ; { n(X) cis_lt YL } -> kill(MState, Ps), B = 0 ; [] ) ) ; nonvar(Y) -> { fd_get(X, _, XL, XU, _) }, ( { XL cis_geq n(Y) } -> kill(MState, Ps), B = 1 ; { XU cis_lt n(Y) } -> kill(MState, Ps), B = 0 ; [] ) ; X == Y -> kill(MState, Ps), B = 1 ; { fd_get(X, _, XL, XU, _), fd_get(Y, _, YL, YU, _) }, ( { XL cis_geq YU } -> kill(MState, Ps), B = 1 ; { XU cis_lt YL } -> kill(MState, Ps), B = 0 ; [] ) ) ; B =:= 0 -> { kill(MState), X #< Y } ; [] ) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(reified_eq(DX,X,DY,Y,Ps,B), MState) --> ( DX == 0 -> kill(MState, Ps), B = 0 ; DY == 0 -> kill(MState, Ps), B = 0 ; B == 1 -> kill(MState), DX = 1, DY = 1, X = Y ; DX == 1, DY == 1 -> ( var(B) -> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), ( X =:= Y -> B = 1 ; B = 0) ; { fd_get(Y, YD, _) }, ( { domain_contains(YD, X) } -> [] ; kill(MState, Ps), B = 0 ) ) ; nonvar(Y) -> run_propagator(reified_eq(DY,Y,DX,X,Ps,B), MState) ; X == Y -> kill(MState), B = 1 ; { fd_get(X, _, XL, XU, _), fd_get(Y, _, YL, YU, _) }, ( { XL cis_gt YU } -> kill(MState, Ps), B = 0 ; { YL cis_gt XU } -> kill(MState, Ps), B = 0 ; [] ) ) ; B =:= 0 -> kill(MState), { X #\= Y } ; [] ) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(reified_neq(DX,X,DY,Y,Ps,B), MState) --> ( DX == 0 -> kill(MState, Ps), B = 0 ; DY == 0 -> kill(MState, Ps), B = 0 ; B == 1 -> { kill(MState), DX = 1, DY = 1, X #\= Y } ; DX == 1, DY == 1 -> ( var(B) -> ( nonvar(X) -> ( nonvar(Y) -> kill(MState), ( X =\= Y -> B = 1 ; B = 0) ; { fd_get(Y, YD, _) }, ( { domain_contains(YD, X) } -> [] ; kill(MState, Ps), B = 1 ) ) ; nonvar(Y) -> run_propagator(reified_neq(DY,Y,DX,X,Ps,B), MState) ; X == Y -> kill(MState), B = 0 ; { fd_get(X, _, XL, XU, _), fd_get(Y, _, YL, YU, _) }, ( { XL cis_gt YU } -> kill(MState, Ps), B = 1 ; { YL cis_gt XU } -> kill(MState, Ps), B = 1 ; [] ) ) ; B =:= 0 -> kill(MState), X = Y ; [] ) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(reified_and(X,Ps1,Y,Ps2,B), MState) --> ( nonvar(X) -> kill(MState), ( X =:= 0 -> { maplist(kill_entailed, Ps2), B = 0 } ; B = Y ) ; nonvar(Y) -> run_propagator(reified_and(Y,Ps2,X,Ps1,B), MState) ; B == 1 -> kill(MState), X = 1, Y = 1 ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(reified_or(X,Ps1,Y,Ps2,B), MState) --> ( nonvar(X) -> kill(MState), ( X =:= 1 -> { maplist(kill_entailed, Ps2), B = 1 } ; B = Y ) ; nonvar(Y) -> run_propagator(reified_or(Y,Ps2,X,Ps1,B), MState) ; B == 0 -> kill(MState), X = 0, Y = 0 ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(reified_not(X,Y), MState) --> ( X == 0 -> kill(MState), Y = 1 ; X == 1 -> kill(MState), Y = 0 ; Y == 0 -> kill(MState), X = 1 ; Y == 1 -> kill(MState), X = 0 ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(pimpl(X, Y, Ps), MState) --> ( nonvar(X) -> kill(MState), ( X =:= 1 -> Y = 1 ; { maplist(kill_entailed, Ps) } ) ; nonvar(Y) -> kill(MState), ( Y =:= 0 -> X = 0 ; { maplist(kill_entailed, Ps) } ) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(preified_slash(X, Y, D, R), MState) --> ( Y == 0 -> kill(MState), D = 0 ; Y == 1 -> kill(MState), D = 1, R = X ; nonvar(X), nonvar(Y) -> kill(MState), ( X mod Y =:= 0 -> D = 1, R is X // Y ; D = 0 ) ; D == 1 -> kill(MState), queue_goal(X/Y #= R) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% run_propagator(preified_exp(X, Y, D, R), MState) --> ( X == 1 -> kill(MState), D = 1, R = 1 ; Y == 0 -> kill(MState), D = 1, R = 1 ; Y == 1 -> kill(MState), D = 1, R = X ; nonvar(X), nonvar(Y) -> kill(MState), ( ( abs(X) =:= 1 ; Y >= 0 ) -> D = 1, R is X^Y ; D = 0 ) ; D == 1 -> kill(MState), queue_goal(X^Y #= R) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% update_bounds(X, XD, XPs, XL, XU, NXL, NXU) --> ( NXL == XL, NXU == XU -> [] ; { domains_intersection(XD, from_to(NXL, NXU), NXD) }, fd_put(X, NXD, XPs) ). min_product(L1, U1, L2, U2, Min) :- Min cis min(min(L1*L2,L1*U2),min(U1*L2,U1*U2)). max_product(L1, U1, L2, U2, Max) :- Max cis max(max(L1*L2,L1*U2),max(U1*L2,U1*U2)). finite(n(_)). in_(L, U, X) :- fd_get(X, XD, XPs), domains_intersection(XD, from_to(L,U), NXD), fd_put(X, NXD, XPs). min_max_factor(L1, U1, L2, U2, L3, U3, Min, Max) :- % use findall/3 to forget auxiliary constraints that are only % needed temporarily for reasoning about domain boundaries findall(Min-Max, min_max_factor_(L1, U1, L2, U2, L3, U3, Min, Max), [Min-Max]). min_max_factor_(L1, U1, L2, U2, L3, U3, Min, Max) :- ( U1 cis_lt n(0), L2 cis_lt n(0), U2 cis_gt n(0), L3 cis_lt n(0), U3 cis_gt n(0) -> maplist(in_(L1,U1), [Z1,Z2]), in_(L2, n(-1), X1), in_(n(1), U3, Y1), ( X1*Y1 #= Z1 -> ( fd_get(Y1, _, Inf1, Sup1, _) -> true ; Inf1 = n(Y1), Sup1 = n(Y1) ) ; Inf1 = inf, Sup1 = n(-1) ), in_(n(1), U2, X2), in_(L3, n(-1), Y2), ( X2*Y2 #= Z2 -> ( fd_get(Y2, _, Inf2, Sup2, _) -> true ; Inf2 = n(Y2), Sup2 = n(Y2) ) ; Inf2 = n(1), Sup2 = sup ), Min cis max(min(Inf1,Inf2), L3), Max cis min(max(Sup1,Sup2), U3) ; L1 cis_gt n(0), L2 cis_lt n(0), U2 cis_gt n(0), L3 cis_lt n(0), U3 cis_gt n(0) -> maplist(in_(L1,U1), [Z1,Z2]), in_(L2, n(-1), X1), in_(L3, n(-1), Y1), ( X1*Y1 #= Z1 -> ( fd_get(Y1, _, Inf1, Sup1, _) -> true ; Inf1 = n(Y1), Sup1 = n(Y1) ) ; Inf1 = n(1), Sup1 = sup ), in_(n(1), U2, X2), in_(n(1), U3, Y2), ( X2*Y2 #= Z2 -> ( fd_get(Y2, _, Inf2, Sup2, _) -> true ; Inf2 = n(Y2), Sup2 = n(Y2) ) ; Inf2 = inf, Sup2 = n(-1) ), Min cis max(min(Inf1,Inf2), L3), Max cis min(max(Sup1,Sup2), U3) ; min_factor(L1, U1, L2, U2, Min0), Min cis max(L3,Min0), max_factor(L1, U1, L2, U2, Max0), Max cis min(U3,Max0) ). min_factor(L1, U1, L2, U2, Min) :- ( L1 cis_geq n(0), L2 cis_gt n(0), finite(U2) -> Min cis div(L1+U2-n(1),U2) ; L1 cis_gt n(0), U2 cis_lt n(0) -> Min cis div(U1,U2) ; L1 cis_gt n(0), L2 cis_geq n(0) -> Min = n(1) ; L1 cis_gt n(0) -> Min cis -U1 ; U1 cis_lt n(0), U2 cis_leq n(0) -> ( finite(L2) -> Min cis div(U1+L2+n(1),L2) ; Min = n(1) ) ; U1 cis_lt n(0), L2 cis_geq n(0) -> Min cis div(L1,L2) ; U1 cis_lt n(0) -> Min = L1 ; L2 cis_leq n(0), U2 cis_geq n(0) -> Min = inf ; Min cis min(min(div(L1,L2),div(L1,U2)),min(div(U1,L2),div(U1,U2))) ). max_factor(L1, U1, L2, U2, Max) :- ( L1 cis_geq n(0), L2 cis_geq n(0) -> Max cis div(U1,L2) ; L1 cis_gt n(0), U2 cis_leq n(0) -> ( finite(L2) -> Max cis div(L1-L2-n(1),L2) ; Max = n(-1) ) ; L1 cis_gt n(0) -> Max = U1 ; U1 cis_lt n(0), U2 cis_lt n(0) -> Max cis div(L1,U2) ; U1 cis_lt n(0), L2 cis_geq n(0) -> ( finite(U2) -> Max cis div(U1-U2+n(1),U2) ; Max = n(-1) ) ; U1 cis_lt n(0) -> Max cis -L1 ; L2 cis_leq n(0), U2 cis_geq n(0) -> Max = sup ; Max cis max(max(div(L1,L2),div(L1,U2)),max(div(U1,L2),div(U1,U2))) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - J-C. Rgin: "A filtering algorithm for constraints of difference in CSPs", AAAI-94, Seattle, WA, USA, pp 362--367, 1994 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ distinct_attach([], _, _) --> []. distinct_attach([X|Xs], Prop, Right) --> ( var(X) -> init_propagator_([X], Prop), { make_propagator(pexclude(Xs,Right,X), P1) }, init_propagator_([X], P1), trigger_prop(P1) ; exclude_fire(Xs, Right, X) ), distinct_attach(Xs, Prop, [X|Right]). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - For each integer of the union of domains, an attributed variable is introduced, to benefit from constant-time access. Attributes are: value ... integer corresponding to the node free ... whether this (right) node is still free edges ... [flow_from(F,From)] and [flow_to(F,To)] where F has an attribute "flow" that is either 0 or 1 and an attribute "used" if it is part of a maximum matching parent ... used in breadth-first search g0_edges ... [flow_to(F,To)] as above visited ... true if node was visited in DFS index, in_stack, lowlink ... used in Tarjan's SCC algorithm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ difference_arcs(Vars, FreeLeft, FreeRight) :- empty_assoc(E), phrase(difference_arcs(Vars, FreeLeft), [E], [NumVar]), assoc_to_list(NumVar, LsNumVar), pairs_values(LsNumVar, FreeRight). domain_to_list(Domain, List) :- phrase(domain_to_list(Domain), List). domain_to_list(split(_, Left, Right)) --> domain_to_list(Left), domain_to_list(Right). domain_to_list(empty) --> []. domain_to_list(from_to(n(F),n(T))) --> { numlist(F, T, Ns) }, seq(Ns). difference_arcs([], []) --> []. difference_arcs([V|Vs], FL0) --> ( { fd_get(V, Dom, _), domain_to_list(Dom, Ns) } -> { FL0 = [V|FL] }, enumerate(Ns, V), difference_arcs(Vs, FL) ; difference_arcs(Vs, FL0) ). writeln(T) :- write(T), nl. :- meta_predicate must_succeed(0). must_succeed(G) :- ( G -> true ; throw(failed-G) ). enumerate([], _) --> []. enumerate([N|Ns], V) --> state(NumVar0, NumVar), { ( get_assoc(N, NumVar0, Y) -> NumVar0 = NumVar ; put_assoc(N, NumVar0, Y, NumVar), put_attr(Y, value, N) ), put_attr(F, flow, 0), must_succeed(append_edge(Y, edges, flow_from(F,V))), must_succeed(append_edge(V, edges, flow_to(F,Y))) }, enumerate(Ns, V). append_edge(V, Attr, E) :- ( get_attr_(Attr, V, Es) -> put_attr_(Attr, V, [E|Es]) ; put_attr_(Attr, V, [E]) ). get_attr_(edges, V, Es) :- get_attr(V, edges, Es). get_attr_(g0_edges, V, Es) :- get_attr(V, g0_edges, Es). put_attr_(edges, V, E) :- put_attr(V, edges, E). put_attr_(g0_edges, V, E) :- put_attr(V, g0_edges, E). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Strategy: Breadth-first search until we find a free right vertex in the value graph, then find an augmenting path in reverse. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ clear_parent(V) :- del_attr(V, parent). maximum_matching([]). maximum_matching([FL|FLs]) :- augmenting_path_to([[FL]], Levels, To), phrase(augmenting_path(FL, To), Path), maplist(maplist(clear_parent), Levels), del_attr(To, free), adjust_alternate_1(Path), maximum_matching(FLs). reachables([]) --> []. reachables([V|Vs]) --> { get_attr(V, edges, Es) }, reachables_(Es, V), reachables(Vs). reachables_([], _) --> []. reachables_([E|Es], V) --> edge_reachable(E, V), reachables_(Es, V). edge_reachable(flow_to(F,To), V) --> ( { get_attr(F, flow, 0), \+ get_attr(To, parent, _) } -> { put_attr(To, parent, V-F) }, [To] ; [] ). edge_reachable(flow_from(F,From), V) --> ( { get_attr(F, flow, 1), \+ get_attr(From, parent, _) } -> { put_attr(From, parent, V-F) }, [From] ; [] ). augmenting_path_to(Levels0, Levels, Right) :- Levels0 = [Vs|_], Levels1 = [Tos|Levels0], phrase(reachables(Vs), Tos), Tos = [_|_], ( member(Right, Tos), get_attr(Right, free, true) -> Levels = Levels1 ; augmenting_path_to(Levels1, Levels, Right) ). augmenting_path(S, V) --> ( { V == S } -> [] ; { get_attr(V, parent, V1-Augment) }, [Augment], augmenting_path(S, V1) ). adjust_alternate_1([A|Arcs]) :- put_attr(A, flow, 1), adjust_alternate_0(Arcs). adjust_alternate_0([]). adjust_alternate_0([A|Arcs]) :- put_attr(A, flow, 0), adjust_alternate_1(Arcs). % Instead of applying Berge's property directly, we can translate the % problem in such a way, that we have to search for the so-called % strongly connected components of the graph. g_g0(V) :- get_attr(V, edges, Es), maplist(g_g0_(V), Es). g_g0_(V, flow_to(F,To)) :- ( get_attr(F, flow, 1) -> append_edge(V, g0_edges, flow_to(F,To)) ; append_edge(To, g0_edges, flow_to(F,V)) ). g0_successors(V, Tos) :- ( get_attr(V, g0_edges, Tos0) -> maplist(arg(2), Tos0, Tos) ; Tos = [] ). put_free(F) :- put_attr(F, free, true). free_node(F) :- get_attr(F, free, true). :- meta_predicate with_local_attributes(?, 0, ?). :- dynamic(nat_copy/1). with_local_attributes(Vars, Goal, Result) :- catch((Goal, % Create a copy where all attributes are removed. Only % the result and its relation to Vars matters. We throw % an exception to undo all modifications to attributes % we made during propagation, and unify the variables % in the thrown copy with Vars in order to get the % intended variables in Result. copy_term_nat(Vars-Result, Copy), throw(local_attributes(Copy))), local_attributes(Vars-Result), true). distinct(Vars) --> { with_local_attributes(Vars, ( difference_arcs(Vars, FreeLeft, FreeRight0), length(FreeLeft, LFL), length(FreeRight0, LFR), LFL =< LFR, maplist(put_free, FreeRight0), maximum_matching(FreeLeft), include(free_node, FreeRight0, FreeRight), maplist(g_g0, FreeLeft), scc(FreeLeft, g0_successors), maplist(dfs_used, FreeRight), phrase(distinct_goals(FreeLeft), Gs)), Gs) }, disable_queue, neq_nums(Gs), enable_queue. neq_nums([]) --> []. neq_nums([neq_num(V,N)|VNs]) --> % { portray_clause(neq_num(V, N)) }, neq_num(V, N), neq_nums(VNs). distinct_goals([]) --> []. distinct_goals([V|Vs]) --> { get_attr(V, edges, Es) }, distinct_goals_(Es, V), distinct_goals(Vs). distinct_goals_([], _) --> []. distinct_goals_([flow_to(F,To)|Es], V) --> ( { get_attr(F, flow, 0), \+ get_attr(F, used, true), get_attr(V, lowlink, L1), get_attr(To, lowlink, L2), L1 =\= L2 } -> { get_attr(To, value, N) }, [neq_num(V, N)] ; [] ), distinct_goals_(Es, V). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mark used edges. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ dfs_used(V) :- ( get_attr(V, visited, true) -> true ; put_attr(V, visited, true), ( get_attr(V, g0_edges, Es) -> dfs_used_edges(Es) ; true ) ). dfs_used_edges([]). dfs_used_edges([flow_to(F,To)|Es]) :- put_attr(F, used, true), dfs_used(To), dfs_used_edges(Es). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Tarjan's strongly connected components algorithm. DCGs are used to implicitly pass around the global index, stack and the predicate relating a vertex to its successors. For more information about this technique, see: path_to_url =================================== A Prolog implementation of this algorithm is also available as a standalone library from: path_to_url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ scc(Vs, Succ) :- phrase(scc(Vs), [s(0,[],Succ)], _). scc([]) --> []. scc([V|Vs]) --> ( vindex_defined(V) -> scc(Vs) ; scc_(V), scc(Vs) ). vindex_defined(V) --> { get_attr(V, index, _) }. vindex_is_index(V) --> state(s(Index,_,_)), { put_attr(V, index, Index) }. vlowlink_is_index(V) --> state(s(Index,_,_)), { put_attr(V, lowlink, Index) }. index_plus_one --> state(s(I,Stack,Succ), s(I1,Stack,Succ)), { I1 is I+1 }. s_push(V) --> state(s(I,Stack,Succ), s(I,[V|Stack],Succ)), { put_attr(V, in_stack, true) }. vlowlink_min_lowlink(V, VP) --> { get_attr(V, lowlink, VL), get_attr(VP, lowlink, VPL), VL1 is min(VL, VPL), put_attr(V, lowlink, VL1) }. successors(V, Tos) --> state(s(_,_,Succ)), { call(Succ, V, Tos) }. scc_(V) --> vindex_is_index(V), vlowlink_is_index(V), index_plus_one, s_push(V), successors(V, Tos), each_edge(Tos, V), ( { get_attr(V, index, VI), get_attr(V, lowlink, VI) } -> pop_stack_to(V, VI) ; [] ). pop_stack_to(V, N) --> state(s(I,[First|Stack],Succ), s(I,Stack,Succ)), { del_attr(First, in_stack) }, ( { First == V } -> [] ; { put_attr(First, lowlink, N) }, pop_stack_to(V, N) ). each_edge([], _) --> []. each_edge([VP|VPs], V) --> ( vindex_defined(VP) -> ( v_in_stack(VP) -> vlowlink_min_lowlink(V, VP) ; [] ) ; scc_(VP), vlowlink_min_lowlink(V, VP) ), each_edge(VPs, V). state(S), [S] --> [S]. state(S0, S), [S] --> [S0]. v_in_stack(V) --> { get_attr(V, in_stack, true) }. node_lowlink(V, L) :- get_attr(V, lowlink, L). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - nvalue/2: A relaxed version of all_distinct/1. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ maximal_matching([]) --> []. maximal_matching([FL|FLs]) --> ( { augmenting_path_to([[FL]], Levels, To) } -> { phrase(augmenting_path(FL, To), Path), maplist(maplist(clear_parent), Levels), del_attr(To, free), adjust_alternate_1(Path) }, [FL] ; [] ), maximal_matching(FLs). propagate_nvalue(N, Vars0) :- sort(Vars0, Vars), include(integer, Vars, Ints), length(Ints, Distinct), vars_num_infinite(Vars, NumInfinite), N #>= Distinct, with_local_attributes(Vars, ( difference_arcs(Vars, FreeLeft, FreeRight0), maplist(put_free, FreeRight0), phrase(maximal_matching(FreeLeft), MatchedLeft), length(MatchedLeft, MaxFurther) ), MaxFurther), N #=< NumInfinite + Distinct + MaxFurther. vars_num_infinite(Vars, Num) :- foldl(num_infinite, Vars, 0, Num). num_infinite(Var, N0, N) :- ( integer(Var) -> N = N0 ; fd_get(Var, Dom, _), ( domain_infimum(Dom, n(_)), domain_supremum(Dom, n(_)) -> N = N0 ; N #= N0 + 1 ) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Weak arc consistent constraint of difference, currently only available internally. Candidate for all_different/2 option. See Neng-Fa Zhou: "Programming Finite-Domain Constraint Propagators in Action Rules", Theory and Practice of Logic Programming, Vol.6, No.5, pp 483-508, 2006 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ weak_arc_all_distinct(Ls) :- must_be(list, Ls), Orig = original_goal(_, weak_arc_all_distinct(Ls)), all_distinct(Ls, [], Orig). all_distinct([], _, _). all_distinct([X|Right], Left, Orig) :- %\+ list_contains(Right, X), ( var(X) -> make_propagator(weak_distinct(Left,Right,X,Orig), Prop), init_propagator(X, Prop), trigger_prop(Prop) % make_propagator(check_distinct(Left,Right,X), Prop2), % init_propagator(X, Prop2), % trigger_prop(Prop2) ; exclude_fire(Left, Right, X) ), outof_reducer(Left, Right, X), all_distinct(Right, [X|Left], Orig). exclude_fire(Left, Right, E) :- all_neq(Left, E), all_neq(Right, E). exclude_fire(Left, Right, E) --> all_neq(Left, E), all_neq(Right, E). list_contains([X|Xs], Y) :- ( X == Y -> true ; list_contains(Xs, Y) ). kill_if_isolated(Left, Right, X, MState) :- append(Left, Right, Others), fd_get(X, XDom, _), ( all_empty_intersection(Others, XDom) -> kill(MState) ; true ). all_empty_intersection([], _). all_empty_intersection([V|Vs], XDom) :- ( fd_get(V, VDom, _) -> domains_intersection_(VDom, XDom, empty), all_empty_intersection(Vs, XDom) ; all_empty_intersection(Vs, XDom) ). outof_reducer(Left, Right, Var) :- ( fd_get(Var, Dom, _) -> append(Left, Right, Others), domain_num_elements(Dom, N), num_subsets(Others, Dom, 0, Num, NonSubs), ( n(Num) cis_geq N -> false ; n(Num) cis N - n(1) -> reduce_from_others(NonSubs, Dom) ; true ) ; %\+ list_contains(Right, Var), %\+ list_contains(Left, Var) true ). reduce_from_others([], _). reduce_from_others([X|Xs], Dom) :- ( fd_get(X, XDom, XPs) -> domain_subtract(XDom, Dom, NXDom), fd_put(X, NXDom, XPs) ; true ), reduce_from_others(Xs, Dom). num_subsets([], _Dom, Num, Num, []). num_subsets([S|Ss], Dom, Num0, Num, NonSubs) :- ( fd_get(S, SDom, _) -> ( domain_subdomain(Dom, SDom) -> Num1 is Num0 + 1, num_subsets(Ss, Dom, Num1, Num, NonSubs) ; NonSubs = [S|Rest], num_subsets(Ss, Dom, Num0, Num, Rest) ) ; num_subsets(Ss, Dom, Num0, Num, NonSubs) ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% serialized(+Starts, +Durations) % % Describes a set of non-overlapping tasks. % Starts = [S_1,...,S_n], is a list of variables or integers, % Durations = [D_1,...,D_n] is a list of non-negative integers. % Constrains Starts and Durations to denote a set of % non-overlapping tasks, i.e.: S_i + D_i =< S_j or S_j + D_j =< % S_i for all 1 =< i < j =< n. Example: % % ``` % ?- length(Vs, 3), % Vs ins 0..3, % serialized(Vs, [1,2,3]), % label(Vs). % Vs = [0,1,3] % ; Vs = [2,0,3] % ; false. % ``` % % @see Dorndorf et al. 2000, "Constraint Propagation Techniques for the % Disjunctive Scheduling Problem" serialized(Starts, Durations) :- must_be(list(integer), Durations), pairs_keys_values(SDs, Starts, Durations), Orig = original_goal(_, serialized(Starts, Durations)), serialize(SDs, Orig). serialize([], _). serialize([S-D|SDs], Orig) :- D >= 0, serialize(SDs, S, D, Orig), serialize(SDs, Orig). serialize([], _, _, _). serialize([S-D|Rest], S0, D0, Orig) :- D >= 0, propagator_init_trigger([S0,S], pserialized(S,D,S0,D0,Orig)), serialize(Rest, S0, D0, Orig). % consistency check / propagation % Currently implements 2-b-consistency earliest_start_time(Start, EST) :- ( fd_get(Start, D, _) -> domain_infimum(D, EST) ; EST = n(Start) ). latest_start_time(Start, LST) :- ( fd_get(Start, D, _) -> domain_supremum(D, LST) ; LST = n(Start) ). serialize_lower_upper(S_I, D_I, S_J, D_J, MState) --> ( { var(S_I) } -> serialize_lower_bound(S_I, D_I, S_J, D_J, MState), ( { var(S_I) } -> serialize_upper_bound(S_I, D_I, S_J, D_J, MState) ; [] ) ; [] ). serialize_lower_bound(I, D_I, J, D_J, MState) --> { fd_get(I, DomI, Ps) }, ( { domain_infimum(DomI, n(EST_I)), latest_start_time(J, n(LST_J)), EST_I + D_I > LST_J, earliest_start_time(J, n(EST_J)) } -> ( nonvar(J) -> kill(MState) ; [] ), { EST is EST_J+D_J, domain_remove_smaller_than(DomI, EST, DomI1) }, fd_put(I, DomI1, Ps) ; [] ). serialize_upper_bound(I, D_I, J, D_J, MState) --> { fd_get(I, DomI, Ps) }, ( { domain_supremum(DomI, n(LST_I)), earliest_start_time(J, n(EST_J)), EST_J + D_J > LST_I, latest_start_time(J, n(LST_J)) } -> ( nonvar(J) -> kill(MState) ; [] ), { LST is LST_J-D_I, domain_remove_greater_than(DomI, LST, DomI1) }, fd_put(I, DomI1, Ps) ; [] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% element(?N, +Vs, ?V) % % The N-th element of the list of finite domain variables Vs is V. % Analogous to nth1/3. element(N, Is, V) :- must_be(list, Is), length(Is, L), N in 1..L, element_(Is, 1, N, V), propagator_init_trigger([N|Is], pelement(N,Is,V)). element_domain(V, VD) :- ( fd_get(V, VD, _) -> true ; VD = from_to(n(V), n(V)) ). element_([], _, _, _). element_([I|Is], N0, N, V) :- #I #\= #V #==> #N #\= N0, N1 is N0 + 1, element_(Is, N1, N, V). integers_remaining([], _, _, D, D). integers_remaining([V|Vs], N0, Dom, D0, D) :- ( domain_contains(Dom, N0) -> element_domain(V, VD), domains_union(D0, VD, D1) ; D1 = D0 ), N1 is N0 + 1, integers_remaining(Vs, N1, Dom, D1, D). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% global_cardinality(+Vs, +Pairs) % % Global Cardinality constraint. Equivalent to % `global_cardinality(Vs, Pairs, [])`. Example: % % ``` % ?- Vs = [_,_,_], global_cardinality(Vs, [1-2,3-_]), label(Vs). % Vs = [1,1,3] % ; Vs = [1,3,1] % ; Vs = [3,1,1] % ; false. % ``` global_cardinality(Xs, Pairs) :- global_cardinality(Xs, Pairs, []). %% global_cardinality(+Vs, +Pairs, +Options) % % Global Cardinality constraint. Vs is a list of finite domain % variables, Pairs is a list of Key-Num pairs, where Key is an % integer and Num is a finite domain variable. The constraint holds % iff each V in Vs is equal to some key, and for each Key-Num pair % in Pairs, the number of occurrences of Key in Vs is Num. Options % is a list of options. Supported options are: % % `consistency(value)` % A weaker form of consistency is used. % % `cost(Cost, Matrix)` % Matrix is a list of rows, one for each variable, in the order % they occur in Vs. Each of these rows is a list of integers, one % for each key, in the order these keys occur in Pairs. When % variable v\_i is assigned the value of key k\_j, then the % associated cost is Matrix\_{ij}. Cost is the sum of all costs. global_cardinality(Xs, Pairs, Options) :- must_be(list(list), [Xs,Pairs,Options]), maplist(fd_variable, Xs), maplist(gcc_pair, Pairs), pairs_keys_values(Pairs, Keys, Nums), ( sort(Keys, Keys1), same_length(Keys, Keys1) -> true ; domain_error(gcc_unique_key_pairs, Pairs) ), length(Xs, L), Nums ins 0..L, list_to_drep(Keys, Drep), Xs ins Drep, gcc_pairs(Pairs, Xs, Pairs1), % pgcc_check must be installed before triggering other % propagators propagator_init_trigger(Xs, pgcc_check(Pairs1)), propagator_init_trigger(Nums, pgcc_check_single(Pairs1)), ( member(OD, Options), OD == consistency(value) -> true ; propagator_init_trigger(Nums, pgcc_single(Xs, Pairs1)), propagator_init_trigger(Xs, pgcc(Xs, Pairs, Pairs1)) ), ( member(OC, Options), functor(OC, cost, 2) -> OC = cost(Cost, Matrix), must_be(list(list(integer)), Matrix), maplist(keys_costs(Keys), Xs, Matrix, Costs), sum(Costs, #=, Cost) ; true ). keys_costs(Keys, X, Row, C) :- element(N, Keys, X), element(N, Row, C). gcc_pair(Pair) :- ( Pair = Key-Val -> must_be(integer, Key), fd_variable(Val) ; domain_error(gcc_pair, Pair) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - For each Key-Num0 pair, we introduce an auxiliary variable Num and attach the following attributes to it: clpz_gcc_num: equal Num0, the user-visible counter variable clpz_gcc_vs: the remaining variables in the constraint that can be equal Key. clpz_gcc_occurred: stores how often Key already occurred in vs. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ gcc_pairs([], _, []). gcc_pairs([Key-Num0|KNs], Vs, [Key-Num|Rest]) :- put_attr(Num, clpz_gcc_num, Num0), put_attr(Num, clpz_gcc_vs, Vs), put_attr(Num, clpz_gcc_occurred, 0), gcc_pairs(KNs, Vs, Rest). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - J.-C. Rgin: "Generalized Arc Consistency for Global Cardinality Constraint", AAAI-96 Portland, OR, USA, pp 209--215, 1996 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ gcc_global(Vs, KNs) --> % at this point, all elements of clpz_gcc_vs must be % variables, which a previously scheduled and called % gcc_check//1 ensures. Note that gcc_check//1 disables the % queue and accumulates constraints in the queue. Do we need % to insert a call of do_queue//0 here to reach a fixpoint? I % think not, because verify_attributes/3 gives each variable % that is involved in a unification an opportunity to schedule % its propagators, even if the unifications happen % simultaneously (such as [A,B] = [0,1], which can happen in % the propagator of tuples_in/2). Hence: We need this only if % an example shows it, ideally found by a systematic search % that can be used to test the implementation. { with_local_attributes(Vs, (gcc_arcs(KNs, S, Vals), variables_with_num_occurrences(Vs, VNs), maplist(target_to_v(T), VNs), ( get_attr(S, edges, Es) -> put_attr(S, parent, none), % Mark S as seen to avoid going back to S. feasible_flow(Es, S, T), % First construct a feasible flow (if any) maximum_flow(S, T), % only then, maximize it. gcc_consistent(T), scc(Vals, gcc_successors), phrase(gcc_goals(Vals), Gs) ; Gs = [] )), Gs) }, disable_queue, neq_nums(Gs), enable_queue. gcc_consistent(T) :- get_attr(T, edges, Es), maplist(saturated_arc, Es). saturated_arc(arc_from(_,U,_,Flow)) :- get_attr(Flow, flow, U). gcc_goals([]) --> []. gcc_goals([Val|Vals]) --> { get_attr(Val, edges, Es) }, gcc_edges_goals(Es, Val), gcc_goals(Vals). gcc_edges_goals([], _) --> []. gcc_edges_goals([E|Es], Val) --> gcc_edge_goal(E, Val), gcc_edges_goals(Es, Val). gcc_edge_goal(arc_from(_,_,_,_), _) --> []. gcc_edge_goal(arc_to(_,_,V,F), Val) --> ( { get_attr(F, flow, 0), get_attr(V, lowlink, L1), get_attr(Val, lowlink, L2), L1 =\= L2, get_attr(Val, value, Value) } -> [neq_num(V, Value)] ; [] ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Like in all_distinct/1, first use breadth-first search, then construct an augmenting path in reverse. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ maximum_flow(S, T) :- ( gcc_augmenting_path([[S]], Levels, T) -> phrase(augmenting_path(S, T), Path), Path = [augment(_,First,_)|Rest], path_minimum(Rest, First, Min), maplist(gcc_augment(Min), Path), maplist(maplist(clear_parent), Levels), maximum_flow(S, T) ; true ). feasible_flow([], _, _). feasible_flow([A|As], S, T) :- make_arc_feasible(A, S, T), feasible_flow(As, S, T). make_arc_feasible(A, S, T) :- A = arc_to(L,_,V,F), get_attr(F, flow, Flow), ( Flow >= L -> true ; Diff is L - Flow, put_attr(V, parent, S-augment(F,Diff,+)), gcc_augmenting_path([[V]], Levels, T), phrase(augmenting_path(S, T), Path), path_minimum(Path, Diff, Min), maplist(gcc_augment(Min), Path), maplist(maplist(clear_parent), Levels), make_arc_feasible(A, S, T) ). gcc_augmenting_path(Levels0, Levels, T) :- Levels0 = [Vs|_], Levels1 = [Tos|Levels0], phrase(gcc_reachables(Vs), Tos), Tos = [_|_], ( member(To, Tos), To == T -> Levels = Levels1 ; gcc_augmenting_path(Levels1, Levels, T) ). gcc_reachables([]) --> []. gcc_reachables([V|Vs]) --> { get_attr(V, edges, Es) }, gcc_reachables_(Es, V), gcc_reachables(Vs). gcc_reachables_([], _) --> []. gcc_reachables_([E|Es], V) --> gcc_reachable(E, V), gcc_reachables_(Es, V). gcc_reachable(arc_from(_,_,V,F), P) --> ( { \+ get_attr(V, parent, _), get_attr(F, flow, Flow), Flow > 0 } -> { put_attr(V, parent, P-augment(F,Flow,-)) }, [V] ; [] ). gcc_reachable(arc_to(_L,U,V,F), P) --> ( { \+ get_attr(V, parent, _), get_attr(F, flow, Flow), Flow < U } -> { Diff is U - Flow, put_attr(V, parent, P-augment(F,Diff,+)) }, [V] ; [] ). path_minimum([], Min, Min). path_minimum([augment(_,A,_)|As], Min0, Min) :- Min1 is min(Min0,A), path_minimum(As, Min1, Min). gcc_augment(Min, augment(F,_,Sign)) :- get_attr(F, flow, Flow0), gcc_flow_(Sign, Flow0, Min, Flow), put_attr(F, flow, Flow). gcc_flow_(+, F0, A, F) :- F is F0 + A. gcc_flow_(-, F0, A, F) :- F is F0 - A. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Build value network for global cardinality constraint. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ gcc_arcs([], _, []). gcc_arcs([Key-Num0|KNs], S, Vals) :- ( get_attr(Num0, clpz_gcc_vs, Vs) -> get_attr(Num0, clpz_gcc_num, Num), get_attr(Num0, clpz_gcc_occurred, Occ), ( nonvar(Num) -> U is Num - Occ, U = L ; fd_get(Num, _, n(L0), n(U0), _), L is L0 - Occ, U is U0 - Occ ), put_attr(Val, value, Key), Vals = [Val|Rest], put_attr(F, flow, 0), append_edge(S, edges, arc_to(L, U, Val, F)), put_attr(Val, edges, [arc_from(L, U, S, F)]), variables_with_num_occurrences(Vs, VNs), maplist(val_to_v(Val), VNs) ; Vals = Rest ), gcc_arcs(KNs, S, Rest). variables_with_num_occurrences(Vs0, VNs) :- include(var, Vs0, Vs1), samsort(Vs1, Vs), ( Vs == [] -> VNs = [] ; Vs = [V|Rest], variables_with_num_occurrences(Rest, V, 1, VNs) ). variables_with_num_occurrences([], Prev, Count, [Prev-Count]). variables_with_num_occurrences([V|Vs], Prev, Count0, VNs) :- ( V == Prev -> Count1 is Count0 + 1, variables_with_num_occurrences(Vs, Prev, Count1, VNs) ; VNs = [Prev-Count0|Rest], variables_with_num_occurrences(Vs, V, 1, Rest) ). target_to_v(T, V-Count) :- put_attr(F, flow, 0), append_edge(V, edges, arc_to(0, Count, T, F)), append_edge(T, edges, arc_from(0, Count, V, F)). val_to_v(Val, V-Count) :- put_attr(F, flow, 0), append_edge(V, edges, arc_from(0, Count, Val, F)), append_edge(Val, edges, arc_to(0, Count, V, F)). gcc_successors(V, Tos) :- get_attr(V, edges, Tos0), phrase(gcc_successors_(Tos0), Tos). gcc_successors_([]) --> []. gcc_successors_([E|Es]) --> gcc_succ_edge(E), gcc_successors_(Es). gcc_succ_edge(arc_to(_,U,V,F)) --> ( { get_attr(F, flow, Flow), Flow < U } -> [V] ; [] ). gcc_succ_edge(arc_from(_,_,V,F)) --> ( { get_attr(F, flow, Flow), Flow > 0 } -> [V] ; [] ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Simple consistency check, run before global propagation. Importantly, it removes all ground values from clpz_gcc_vs. The pgcc_check/1 propagator in itself suffices to ensure consistency. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ gcc_check(Pairs) --> disable_queue, gcc_check_(Pairs), enable_queue. gcc_done(Num) :- del_attr(Num, clpz_gcc_vs), del_attr(Num, clpz_gcc_num), del_attr(Num, clpz_gcc_occurred). gcc_check_([]) --> []. gcc_check_([Key-Num0|KNs]) --> ( { get_attr(Num0, clpz_gcc_vs, Vs) } -> { get_attr(Num0, clpz_gcc_num, Num), get_attr(Num0, clpz_gcc_occurred, Occ0), vs_key_min_others(Vs, Key, 0, Min, Os), put_attr(Num0, clpz_gcc_vs, Os), put_attr(Num0, clpz_gcc_occurred, Occ1), Occ1 is Occ0 + Min }, geq(Num, Occ1), % The queue is disabled for efficiency here in any case. % If it were enabled, make sure to retain the invariant % that gcc_global is never triggered during an % inconsistent state (after gcc_done/1 but before all % relevant constraints are posted). ( Occ1 == Num -> all_neq(Os, Key), { gcc_done(Num0) } ; Os == [] -> { gcc_done(Num0) }, Num = Occ1 ; { length(Os, L), Max is Occ1 + L }, geq(Max, Num), ( { nonvar(Num) } -> Diff is Num - Occ1 ; { fd_get(Num, ND, _), domain_infimum(ND, n(NInf)) }, Diff is NInf - Occ1 ), L >= Diff, ( L =:= Diff -> Num is Occ1 + Diff, { maplist(=(Key), Os), gcc_done(Num0) } ; true ) ) ; true ), gcc_check_(KNs). vs_key_min_others([], _, Min, Min, []). vs_key_min_others([V|Vs], Key, Min0, Min, Others) :- ( fd_get(V, VD, _) -> ( domain_contains(VD, Key) -> Others = [V|Rest], vs_key_min_others(Vs, Key, Min0, Min, Rest) ; vs_key_min_others(Vs, Key, Min0, Min, Others) ) ; ( V =:= Key -> Min1 is Min0 + 1, vs_key_min_others(Vs, Key, Min1, Min, Others) ; vs_key_min_others(Vs, Key, Min0, Min, Others) ) ). all_neq([], _) --> []. all_neq([X|Xs], C) --> neq_num(X, C), all_neq(Xs, C). all_neq([], _). all_neq([X|Xs], C) :- neq_num(X, C), all_neq(Xs, C). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% circuit(+Vs) % % True iff the list Vs of finite domain variables induces a % Hamiltonian circuit. The k-th element of Vs denotes the % successor of node k. Node indexing starts with 1. Examples: % % ``` % ?- length(Vs, _), circuit(Vs), label(Vs). % Vs = [] % ; Vs = [1] % ; Vs = [2,1] % ; Vs = [2,3,1] % ; Vs = [3,1,2] % ; Vs = [2,3,4,1] % ; ... . % ``` circuit(Vs) :- must_be(list, Vs), maplist(fd_variable, Vs), length(Vs, L), Vs ins 1..L, ( L =:= 1 -> true ; neq_index(Vs, 1), make_propagator(pcircuit(Vs), Prop), new_queue(Q0), phrase((distinct_attach(Vs, Prop, []),trigger_prop(Prop),do_queue), [Q0], _) ). neq_index([], _). neq_index([X|Xs], N) :- neq_num(X, N), N1 is N + 1, neq_index(Xs, N1). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Necessary condition for existence of a Hamiltonian circuit: The graph has a single strongly connected component. If the list is ground, the condition is also sufficient. Ts are used as temporary variables to attach attributes: lowlink, index: used for SCC [arc_to(V)]: possible successors - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ propagate_circuit(Vs) :- with_local_attributes([], (same_length(Vs, Ts), circuit_graph(Vs, Ts, Ts), scc(Ts, circuit_successors), maplist(single_component, Ts)), _). single_component(V) :- get_attr(V, lowlink, 0). circuit_graph([], _, _). circuit_graph([V|Vs], Ts0, [T|Ts]) :- ( nonvar(V) -> Ns = [V] ; fd_get(V, Dom, _), domain_to_list(Dom, Ns) ), phrase(circuit_edges(Ns, Ts0), Es), put_attr(T, edges, Es), circuit_graph(Vs, Ts0, Ts). circuit_edges([], _) --> []. circuit_edges([N|Ns], Ts) --> { nth1(N, Ts, T) }, [arc_to(T)], circuit_edges(Ns, Ts). circuit_successors(V, Tos) :- get_attr(V, edges, Tos0), maplist(arg(1), Tos0, Tos). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% cumulative(+Tasks) % % Equivalent to cumulative(Tasks, [limit(1)]). cumulative(Tasks) :- cumulative(Tasks, [limit(1)]). %% cumulative(+Tasks, +Options) % % Schedule with a limited resource. Tasks is a list of tasks, each of % the form task(S_i, D_i, E_i, C_i, T_i). S_i denotes the start time, % D_i the positive duration, E_i the end time, C_i the non-negative % resource consumption, and T_i the task identifier. Each of these % arguments must be a finite domain variable with bounded domain, or % an integer. The constraint holds iff at each time slot during the % start and end of each task, the total resource consumption of all % tasks running at that time does not exceed the global resource % limit. Options is a list of options. Currently, the only supported % option is: % % * limit(L) % The integer L is the global resource limit. Default is 1. % % For example, given the following predicate that relates three tasks % of durations 2 and 3 to a list containing their starting times: % % ``` % tasks_starts(Tasks, [S1,S2,S3]) :- % Tasks = [task(S1,3,_,1,_), % task(S2,2,_,1,_), % task(S3,2,_,1,_)]. % ``` % % We can use cumulative/2 as follows, and obtain a schedule: % % ``` % ?- tasks_starts(Tasks, Starts), Starts ins 0..10, % cumulative(Tasks, [limit(2)]), label(Starts). % Tasks = [task(0, 3, 3, 1, _G36), task(0, 2, 2, 1, _G45), ...], % Starts = [0, 0, 2] . % ``` cumulative(Tasks, Options) :- must_be(list(list), [Tasks,Options]), ( Options = [] -> L = 1 ; Options = [limit(L)] -> must_be(integer, L) ; domain_error(cumulative_options_empty_or_limit, Options) ), ( Tasks = [] -> true ; fully_elastic_relaxation(Tasks, L), maplist(task_bs, Tasks, Bss), maplist(arg(1), Tasks, Starts), maplist(fd_inf, Starts, MinStarts), maplist(arg(3), Tasks, Ends), maplist(fd_sup, Ends, MaxEnds), MinStarts = [Min|Mins], foldl(min_, Mins, Min, Start), MaxEnds = [Max|Maxs], foldl(max_, Maxs, Max, End), resource_limit(Start, End, Tasks, Bss, L) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Trivial lower and upper bounds, assuming no gaps and not necessarily retaining the rectangular shape of each task. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ fully_elastic_relaxation(Tasks, Limit) :- maplist(task_duration_consumption, Tasks, Ds, Cs), maplist(area, Ds, Cs, As), sum(As, #=, #Area), #MinTime #= (Area + Limit - 1) // Limit, tasks_minstart_maxend(Tasks, MinStart, MaxEnd), MaxEnd #>= MinStart + MinTime. task_duration_consumption(task(_,D,_,C,_), D, C). area(X, Y, Area) :- #Area #= #X * #Y. tasks_minstart_maxend(Tasks, Start, End) :- maplist(task_start_end, Tasks, [Start0|Starts], [End0|Ends]), foldl(min_, Starts, Start0, Start), foldl(max_, Ends, End0, End). max_(E, M0, M) :- #M #= max(E, M0). min_(E, M0, M) :- #M #= min(E, M0). task_start_end(task(Start,_,End,_,_), #Start, #End). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - All time slots must respect the resource limit. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ resource_limit(T, T, _, _, _) :- !. resource_limit(T0, T, Tasks, Bss, L) :- maplist(contribution_at(T0), Tasks, Bss, Cs), sum(Cs, #=<, L), T1 is T0 + 1, resource_limit(T1, T, Tasks, Bss, L). task_bs(Task, InfStart-Bs) :- Task = task(Start,D,End,_,_Id), #D #> 0, #End #= #Start + #D, maplist(finite_domain, [End,Start,D]), fd_inf(Start, InfStart), fd_sup(End, SupEnd), L is SupEnd - InfStart, length(Bs, L), task_running(Bs, Start, End, InfStart). task_running([], _, _, _). task_running([B|Bs], Start, End, T) :- ((T #>= Start) #/\ (T #< End)) #<==> #B, T1 is T + 1, task_running(Bs, Start, End, T1). contribution_at(T, Task, Offset-Bs, Contribution) :- Task = task(Start,_,End,C,_), #C #>= 0, fd_inf(Start, InfStart), fd_sup(End, SupEnd), ( T < InfStart -> Contribution = 0 ; T >= SupEnd -> Contribution = 0 ; Index is T - Offset, nth0(Index, Bs, B), #Contribution #= B*C ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% disjoint2(+Rectangles) % % True iff Rectangles are not overlapping. Rectangles is a list of % terms of the form F(X_i, W_i, Y_i, H_i), where F is any functor, % and the arguments are finite domain variables or integers that % denote, respectively, the X coordinate, width, Y coordinate and % height of each rectangle. disjoint2(Rs0) :- must_be(list, Rs0), maplist(=.., Rs0, Rs), non_overlapping(Rs). non_overlapping([]). non_overlapping([R|Rs]) :- maplist(non_overlapping_(R), Rs), non_overlapping(Rs). non_overlapping_(A, B) :- a_not_in_b(A, B), a_not_in_b(B, A). a_not_in_b([_,AX,AW,AY,AH], [_,BX,BW,BY,BH]) :- #AX #=< #BX #/\ #BX #< #AX + #AW #==> #AY + #AH #=< #BY #\/ #BY + #BH #=< #AY, #AY #=< #BY #/\ #BY #< #AY + #AH #==> #AX + #AW #=< #BX #\/ #BX + #BW #=< #AX. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% automaton(+Vs, +Nodes, +Arcs) % % Describes a list of finite domain variables with a finite % automaton. Equivalent to automaton(Vs, _, Vs, Nodes, Arcs, % [], [], _), a common use case of automaton/8. In the following % example, a list of binary finite domain variables is constrained to % contain at least two consecutive ones: % % ``` % two_consecutive_ones(Vs) :- % automaton(Vs, [source(a),sink(c)], % [arc(a,0,a), arc(a,1,b), % arc(b,0,a), arc(b,1,c), % arc(c,0,c), arc(c,1,c)]). % ``` % % Example query: % % ``` % ?- length(Vs, 3), two_consecutive_ones(Vs), label(Vs). % Vs = [0,1,1] % ; Vs = [1,1,0] % ; Vs = [1,1,1] % ; false. % ``` automaton(Sigs, Ns, As) :- automaton(_, _, Sigs, Ns, As, [], [], _). %% automaton(+Sequence, ?Template, +Signature, +Nodes, +Arcs, +Counters, +Initials, ?Finals) % % Describes a list of finite domain variables with a finite % automaton. True iff the finite automaton induced by Nodes and Arcs % (extended with Counters) accepts Signature. Sequence is a list of % terms, all of the same shape. Additional constraints must link % Sequence to Signature, if necessary. Nodes is a list of % source(Node) and sink(Node) terms. Arcs is a list of % arc(Node,Integer,Node) and arc(Node,Integer,Node,Exprs) terms that % denote the automaton's transitions. Each node is represented by an % arbitrary term. Transitions that are not mentioned go to an % implicit failure node. `Exprs` is a list of arithmetic expressions, % of the same length as Counters. In each expression, variables % occurring in Counters symbolically refer to previous counter % values, and variables occurring in Template refer to the current % element of Sequence. When a transition containing arithmetic % expressions is taken, each counter is updated according to the % result of the corresponding expression. When a transition without % arithmetic expressions is taken, all counters remain unchanged. % Counters is a list of variables. Initials is a list of finite % domain variables or integers denoting, in the same order, the % initial value of each counter. These values are related to Finals % according to the arithmetic expressions of the taken transitions. % % The following example is taken from Beldiceanu, Carlsson, Debruyne % and Petit: "Reformulation of Global Constraints Based on % Constraints Checkers", Constraints 10(4), pp 339-362 (2005). It % relates a sequence of integers and finite domain variables to its % number of inflexions, which are switches between strictly ascending % and strictly descending subsequences: % % ``` % sequence_inflexions(Vs, N) :- % variables_signature(Vs, Sigs), % automaton(Sigs, _, Sigs, % [source(s),sink(i),sink(j),sink(s)], % [arc(s,0,s), arc(s,1,j), arc(s,2,i), % arc(i,0,i), arc(i,1,j,[C+1]), arc(i,2,i), % arc(j,0,j), arc(j,1,j), % arc(j,2,i,[C+1])], % [C], [0], [N]). % % variables_signature([], []). % variables_signature([V|Vs], Sigs) :- % variables_signature_(Vs, V, Sigs). % % variables_signature_([], _, []). % variables_signature_([V|Vs], Prev, [S|Sigs]) :- % V #= Prev #<==> S #= 0, % Prev #< V #<==> S #= 1, % Prev #> V #<==> S #= 2, % variables_signature_(Vs, V, Sigs). % ``` % % Example queries: % % ``` % ?- sequence_inflexions([1,2,3,3,2,1,3,0], N). % N = 3. % % ?- length(Ls, 5), Ls ins 0..1, % sequence_inflexions(Ls, 3), label(Ls). % Ls = [0, 1, 0, 1, 0] ; % Ls = [1, 0, 1, 0, 1]. % ``` template_var_path(V, Var, []) :- var(V), !, V == Var. template_var_path(T, Var, [N|Ns]) :- arg(N, T, Arg), template_var_path(Arg, Var, Ns). path_term_variable([], V, V). path_term_variable([P|Ps], T, V) :- arg(P, T, Arg), path_term_variable(Ps, Arg, V). initial_expr(_, []-1). automaton(Seqs, Template, Sigs, Ns, As0, Cs, Is, Fs) :- must_be(list(list), [Sigs,Ns,As0,Cs,Is]), ( var(Seqs) -> ( monotonic -> instantiation_error(Seqs) ; Seqs = Sigs ) ; must_be(list, Seqs) ), maplist(monotonic, Cs, CsM), maplist(arc_normalized(CsM), As0, As), include_args1(sink, Ns, Sinks), include_args1(source, Ns, Sources), maplist(initial_expr, Cs, Exprs0), phrase((arcs_relation(As, Relation), nodes_nums(Sinks, SinkNums0), nodes_nums(Sources, SourceNums0)), [s([]-0, Exprs0)], [s(_,Exprs1)]), maplist(expr0_expr, Exprs1, Exprs), phrase(transitions(Seqs, Template, Sigs, Start, End, Exprs, Cs, Is, Fs), Tuples), list_to_drep(SourceNums0, SourceDrep), Start in SourceDrep, list_to_drep(SinkNums0, SinkDrep), End in SinkDrep, tuples_in(Tuples, Relation). expr0_expr(Es0-_, Es) :- pairs_keys(Es0, Es1), reverse(Es1, Es). transitions([], _, [], S, S, _, _, Cs, Cs) --> []. transitions([Seq|Seqs], Template, [Sig|Sigs], S0, S, Exprs, Counters, Cs0, Cs) --> [[S0,Sig,S1|Is]], { phrase(exprs_next(Exprs, Is, Cs1), [s(Seq,Template,Counters,Cs0)], _) }, transitions(Seqs, Template, Sigs, S1, S, Exprs, Counters, Cs1, Cs). exprs_next([], [], []) --> []. exprs_next([Es|Ess], [I|Is], [C|Cs]) --> exprs_values(Es, Vs), { element(I, Vs, C) }, exprs_next(Ess, Is, Cs). exprs_values([], []) --> []. exprs_values([E0|Es], [V|Vs]) --> { term_variables(E0, EVs0), copy_term(E0, E), term_variables(E, EVs), #V #= E }, match_variables(EVs0, EVs), exprs_values(Es, Vs). match_variables([], _) --> []. match_variables([V0|Vs0], [V|Vs]) --> state(s(Seq,Template,Counters,Cs0)), { ( template_var_path(Template, V0, Ps) -> path_term_variable(Ps, Seq, V) ; template_var_path(Counters, V0, Ps) -> path_term_variable(Ps, Cs0, V) ; domain_error(variable_from_template_or_counters, V0) ) }, match_variables(Vs0, Vs). nodes_nums([], []) --> []. nodes_nums([Node|Nodes], [Num|Nums]) --> node_num(Node, Num), nodes_nums(Nodes, Nums). arcs_relation([], []) --> []. arcs_relation([arc(S0,L,S1,Es)|As], [[From,L,To|Ns]|Rs]) --> node_num(S0, From), node_num(S1, To), state(s(Nodes, Exprs0), s(Nodes, Exprs)), { exprs_nums(Es, Ns, Exprs0, Exprs) }, arcs_relation(As, Rs). exprs_nums([], [], [], []). exprs_nums([E|Es], [N|Ns], [Ex0-C0|Exs0], [Ex-C|Exs]) :- ( member(Exp-N, Ex0), Exp == E -> C = C0, Ex = Ex0 ; N = C0, C is C0 + 1, Ex = [E-C0|Ex0] ), exprs_nums(Es, Ns, Exs0, Exs). node_num(Node, Num) --> state(s(Nodes0-C0, Exprs), s(Nodes-C, Exprs)), { ( member(N-Num, Nodes0), N == Node -> C = C0, Nodes = Nodes0 ; Num = C0, C is C0 + 1, Nodes = [Node-C0|Nodes0] ) }. include_args1(Goal, Ls0, As) :- include(Goal, Ls0, Ls), maplist(arg(1), Ls, As). source(source(_)). sink(sink(_)). monotonic(Var, #Var). arc_normalized(Cs, Arc0, Arc) :- arc_normalized_(Arc0, Cs, Arc). arc_normalized_(arc(S0,L,S,Cs), _, arc(S0,L,S,Cs)). arc_normalized_(arc(S0,L,S), Cs, arc(S0,L,S,Cs)). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% zcompare(?Order, ?A, ?B) % % Analogous to compare/3, with finite domain variables A and B. % % This predicate allows you to make several predicates over integers % deterministic while preserving their generality and completeness. % For example: % % ``` % n_factorial(N, F) :- % zcompare(C, N, 0), % n_factorial_(C, N, F). % % n_factorial_(=, _, 1). % n_factorial_(>, N, F) :- % F #= F0*N, N1 #= N - 1, % n_factorial(N1, F0). % ``` % % This version is deterministic if the first argument is instantiated, % because first argument indexing can distinguish the two different % clauses: % % ``` % ?- n_factorial(30, F). % F = 265252859812191058636308480000000. % ``` % % The predicate can still be used in all directions, including the % most general query: % % ``` % ?- n_factorial(N, F). % N = 0, F = 1 % ; N = 1, F = 1 % ; N = 2, F = 2 % ; ... . % ``` zcompare(Order, A, B) :- ( nonvar(Order) -> zcompare_(Order, A, B) ; integer(A), integer(B) -> compare(Order, A, B) ; freeze(Order, zcompare_(Order, A, B)), fd_variable(A), fd_variable(B), propagator_init_trigger([A,B], pzcompare(Order, A, B)) ). zcompare_(O, A, B) :- ( member(O, "<=>") -> true ; domain_error(order, O, zcompare/3) ), zcompare__(O, A, B). zcompare__(=, A, B) :- #A #= #B. zcompare__(<, A, B) :- #A #< #B. zcompare__(>, A, B) :- #A #> #B. %% chain(+Relation, +Zs) % % Zs form a chain with respect to Relation. Zs is a list of finite % domain variables that are a chain with respect to the partial order % Relation, in the order they appear in the list. Relation must be #=, % #=<, #>=, #< or #>. For example: % % ``` % ?- chain(#>=, [X,Y,Z]). % X#>=Y, % Y#>=Z. % ``` chain(Relation, Zs) :- must_be(list, Zs), maplist(fd_variable, Zs), must_be(ground, Relation), ( chain_relation(Relation) -> true ; domain_error(chain_relation, Relation) ), chain_(Zs, Relation). chain_([], _). chain_([X|Xs], Relation) :- foldl(chain(Relation), Xs, X, _). chain_relation(#=). chain_relation(#<). chain_relation(#=<). chain_relation(#>). chain_relation(#>=). chain(Relation, X, Prev, X) :- call(Relation, #Prev, #X). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Reflection predicates - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ %% fd_var(+Var) % % True iff Var is a CLP() variable. fd_var(X) :- get_attr(X, clpz, _). %% fd_inf(+Var, -Inf) % % Inf is the infimum of the current domain of Var. fd_inf(X, Inf) :- ( fd_get(X, XD, _) -> domain_infimum(XD, Inf0), bound_portray(Inf0, Inf) ; must_be(integer, X), Inf = X ). %% fd_sup(+Var, -Sup) % % Sup is the supremum of the current domain of Var. fd_sup(X, Sup) :- ( fd_get(X, XD, _) -> domain_supremum(XD, Sup0), bound_portray(Sup0, Sup) ; must_be(integer, X), Sup = X ). %% fd_size(+Var, -Size) % % Size is the number of elements of the current domain of Var, or the % atom *sup* if the domain is unbounded. fd_size(X, S) :- ( fd_get(X, XD, _) -> domain_num_elements(XD, S0), bound_portray(S0, S) ; must_be(integer, X), S = 1 ). %% fd_dom(+Var, -Dom) % % Dom is the current domain (see `(in)/2`) of Var. This predicate is % useful if you want to reason about domains. It is _not_ needed if % you only want to display remaining domains; instead, separate your % model from the search part and let the toplevel display this % information via residual goals. % % For example, to implement a custom labeling strategy, you may need % to inspect the current domain of a finite domain variable. With the % following code, you can convert a _finite_ domain to a list of % integers: % % ``` % dom_integers(D, Is) :- phrase(dom_integers_(D), Is). % % dom_integers_(I) --> { integer(I) }, [I]. % dom_integers_(L..U) --> { numlist(L, U, Is) }, Is. % dom_integers_(D1\/D2) --> dom_integers_(D1), dom_integers_(D2). % ``` % % Example: % % ``` % ?- X in 1..5, X #\= 4, fd_dom(X, D), dom_integers(D, Is). % D = 1..3\/5, % Is = [1,2,3,5], % X in 1..3\/5. % ``` fd_dom(X, Drep) :- ( fd_get(X, XD, _) -> domain_to_drep(XD, Drep) ; must_be(integer, X), Drep = X..X ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Entailment detection. Subject to change. Currently, Goals entail E if posting ({#\ E} U Goals), then labeling all variables, fails. E must be reifiable. Examples: %?- clpz:goals_entail([X#>2], X #> 3). %@ false. %?- clpz:goals_entail([X#>1, X#<3], X #= 2). %@ true. %?- clpz:goals_entail([X#=Y+1], X #= Y+1). %@ ERROR: Arguments are not sufficiently instantiated %@ Exception: (15) throw(error(instantiation_error, _G2680)) ? %?- clpz:goals_entail([[X,Y] ins 0..10, X#=Y+1], X #= Y+1). %@ true. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ goals_entail(Goals, E) :- must_be(list, Goals), \+ ( maplist(call, Goals), #\ E, term_variables(Goals-E, Vs), label(Vs) ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unification hook and constraint projection - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ verify_attributes(Var, Other, Gs) :- % portray_clause(Var = Other), ( get_atts(Var, clpz(CLPZ)) -> CLPZ = clpz_attr(_,_,_,Dom,Ps,Q), ( nonvar(Other) -> ( integer(Other) -> true ; type_error(integer, Other) ), domain_contains(Dom, Other), phrase(trigger_props(Ps), [Q], [_]), Gs = [phrase(do_queue, [Q], _)] ; ( get_atts(Other, clpz(clpz_attr(_,_,_,OD,OPs,_))) -> domains_intersection(OD, Dom, Dom1), append_propagators(Ps, OPs, Ps1), new_queue(Q0), variables_same_queue([Var,Other]), phrase((fd_put(Other,Dom1,Ps1), trigger_props(Ps1)), [Q0], _), Gs = [phrase(do_queue, [Q0], _)] ; put_atts(Other, clpz(CLPZ)), Gs = [] ) ) ; Gs = [] ). append_propagators(fd_props(Gs0,Bs0,Os0), fd_props(Gs1,Bs1,Os1), fd_props(Gs,Bs,Os)) :- maplist(append, [Gs0,Bs0,Os0], [Gs1,Bs1,Os1], [Gs,Bs,Os]). bound_portray(inf, inf). bound_portray(sup, sup). bound_portray(n(N), N). list_to_drep(List, Drep) :- list_to_domain(List, Dom), domain_to_drep(Dom, Drep). domain_to_drep(Dom, Drep) :- domain_intervals(Dom, [A0-B0|Rest]), bound_portray(A0, A), bound_portray(B0, B), ( A == B -> Drep0 = A ; Drep0 = A..B ), intervals_to_drep(Rest, Drep0, Drep). intervals_to_drep([], Drep, Drep). intervals_to_drep([A0-B0|Rest], Drep0, Drep) :- bound_portray(A0, A), bound_portray(B0, B), ( A == B -> D1 = A ; D1 = A..B ), intervals_to_drep(Rest, Drep0 \/ D1, Drep). attribute_goals(X) --> % { get_attr(X, clpz, Attr), format("A: ~w\n", [Attr]) }, { get_attr(X, clpz, clpz_attr(_,_,_,Dom,fd_props(Gs,Bs,Os),_)), append(Gs, Bs, Ps0), append(Ps0, Os, Ps), domain_to_drep(Dom, Drep) }, ( { default_domain(Dom), \+ all_dead_(Ps) } -> [] ; [clpz:(X in Drep)] ), attributes_goals(Ps), { del_attr(X, clpz) }. attributes_goals([]) --> []. attributes_goals([propagator(P, State)|As]) --> ( { ground(State) } -> [] ; { phrase(attribute_goal_(P), Gs) } -> { del_attr(State, clpz_aux), State = processed, ( monotonic -> maplist(unwrap_with(bare_integer), Gs, Gs1) ; maplist(unwrap_with(=), Gs, Gs1) ), maplist(with_clpz, Gs1, Gs2) }, seq(Gs2) ; [P] % possibly user-defined constraint ), attributes_goals(As). with_clpz(G, clpz:G). unwrap_with(_, V, V) :- var(V), !. unwrap_with(Goal, #V0, V) :- !, call(Goal, V0, V). unwrap_with(Goal, Term0, Term) :- Term0 =.. [F|Args0], maplist(unwrap_with(Goal), Args0, Args), Term =.. [F|Args]. bare_integer(V0, V) :- ( integer(V0) -> V = V0 ; V = #V0 ). attribute_goal_(presidual(Goal)) --> [Goal]. attribute_goal_(pgeq(A,B)) --> [#A #>= #B]. attribute_goal_(pplus(X,Y,Z,_)) --> [#X + #Y #= #Z]. attribute_goal_(pneq(A,B)) --> [#A #\= #B]. attribute_goal_(ptimes(X,Y,Z,_)) --> [#X * #Y #= #Z]. attribute_goal_(absdiff_neq(X,Y,C)) --> [abs(#X - #Y) #\= C]. attribute_goal_(x_eq_abs_plus_v(X,V)) --> [#X #= abs(#X) + #V]. attribute_goal_(x_neq_y_plus_z(X,Y,Z)) --> [#X #\= #Y + #Z]. attribute_goal_(x_leq_y_plus_c(X,Y,C)) --> [#X #=< #Y + C]. attribute_goal_(ptzdiv(X,Y,Z,_)) --> [#X // #Y #= #Z]. attribute_goal_(pexp(X,Y,Z,_)) --> [#X ^ #Y #= #Z]. attribute_goal_(psign(X,Y)) --> [#Y #= sign(#X)]. attribute_goal_(pabs(X,Y)) --> [#Y #= abs(#X)]. attribute_goal_(pmod(X,M,K)) --> [#X mod #M #= #K]. attribute_goal_(prem(X,Y,Z)) --> [#X rem #Y #= #Z]. attribute_goal_(pmax(X,Y,Z)) --> [#Z #= max(#X,#Y)]. attribute_goal_(pmin(X,Y,Z)) --> [#Z #= min(#X,#Y)]. attribute_goal_(pxor(X,Y,Z)) --> [#Z #= xor(#X, #Y)]. attribute_goal_(ppopcount(X,Y)) --> [#Y #= popcount(#X)]. attribute_goal_(scalar_product_neq(Cs,Vs,C)) --> [Left #\= Right], { scalar_product_left_right([-1|Cs], [C|Vs], Left, Right) }. attribute_goal_(scalar_product_eq(Cs,Vs,C)) --> [Left #= Right], { scalar_product_left_right([-1|Cs], [C|Vs], Left, Right) }. attribute_goal_(scalar_product_leq(Cs,Vs,C)) --> [Left #=< Right], { scalar_product_left_right([-1|Cs], [C|Vs], Left, Right) }. attribute_goal_(pdifferent(_,_,_,O)) --> original_goal(O). attribute_goal_(weak_distinct(_,_,_,O)) --> original_goal(O). attribute_goal_(pdistinct(Vs)) --> [all_distinct(Vs)]. attribute_goal_(pnvalue(N, Vs)) --> [nvalue(N, Vs)]. attribute_goal_(pexclude(_,_,_)) --> []. attribute_goal_(pelement(N,Is,V)) --> [element(N, Is, V)]. attribute_goal_(pgcc(Vs, Pairs, _)) --> [global_cardinality(Vs, Pairs)]. attribute_goal_(pgcc_single(_,_)) --> []. attribute_goal_(pgcc_check_single(_)) --> []. attribute_goal_(pgcc_check(Pairs)) --> { pairs_values(Pairs, Nums), maplist(gcc_done, Nums) }. attribute_goal_(pcircuit(Vs)) --> [circuit(Vs)]. attribute_goal_(pserialized(_,_,_,_,O)) --> original_goal(O). attribute_goal_(rel_tuple(R, Tuple)) --> { get_attr(R, clpz_relation, Rel) }, [tuples_in([Tuple], Rel)]. attribute_goal_(pzcompare(O,A,B)) --> [zcompare(O,A,B)]. % reified constraints attribute_goal_(reified_in(V, D, B)) --> [V in Drep #<==> #B], { domain_to_drep(D, Drep) }. attribute_goal_(reified_tuple_in(Tuple, R, B)) --> { get_attr(R, clpz_relation, Rel) }, [tuples_in([Tuple], Rel) #<==> #B]. attribute_goal_(kill_reified_tuples(_,_,_)) --> []. attribute_goal_(tuples_not_in(_,_,_)) --> []. attribute_goal_(reified_fd(V,B)) --> [finite_domain(V) #<==> #B]. attribute_goal_(pskeleton(X,Y,D,_,Z,F)) --> { Prop =.. [F,X,Y,Z], phrase(attribute_goal_(Prop), Goals), list_goal(Goals, Goal) }, [#D #= 1 #==> Goal, #Y #\= 0 #==> #D #= 1]. attribute_goal_(reified_neq(DX,X,DY,Y,_,B)) --> conjunction(DX, DY, #X #\= #Y, B). attribute_goal_(reified_eq(DX,X,DY,Y,_,B)) --> conjunction(DX, DY, #X #= #Y, B). attribute_goal_(reified_geq(DX,X,DY,Y,_,B)) --> conjunction(DX, DY, #X #>= #Y, B). attribute_goal_(reified_and(X,_,Y,_,B)) --> [#X #/\ #Y #<==> #B]. attribute_goal_(reified_or(X, _, Y, _, B)) --> [#X #\/ #Y #<==> #B]. attribute_goal_(reified_not(X, Y)) --> [#\ #X #<==> #Y]. attribute_goal_(preified_slash(X, Y, _, R)) --> [#X/ #Y #= R]. attribute_goal_(preified_exp(X, Y, _, R)) --> [#X^ #Y #= R]. attribute_goal_(pimpl(X, Y, _)) --> [#X #==> #Y]. attribute_goal_(pfunction(Op, A, B, R)) --> { Expr =.. [Op,#A,#B] }, [#R #= Expr]. attribute_goal_(pfunction(Op, A, R)) --> { Expr =.. [Op,#A] }, [#R #= Expr]. conjunction(A, B, G, D) --> ( { A == 1, B == 1 } -> [G #<==> #D] ; { A == 1 } -> [(#B #/\ G) #<==> #D] ; { B == 1 } -> [(#A #/\ G) #<==> #D] ; [(#A #/\ #B #/\ G) #<==> #D] ). original_goal(original_goal(State, Goal)) --> ( { var(State) } -> { State = processed }, [Goal] ; [] ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Projection of scalar product. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ scalar_product_left_right(Cs, Vs, Left, Right) :- pairs_keys_values(Pairs0, Cs, Vs), partition(ground, Pairs0, Grounds, Pairs), maplist(pair_product, Grounds, Prods), sum_list(Prods, Const), NConst is -Const, partition(compare_coeff0, Pairs, Negatives, _, Positives), maplist(negate_coeff, Negatives, Rights), scalar_plusterm(Rights, Right0), scalar_plusterm(Positives, Left0), ( Const =:= 0 -> Left = Left0, Right = Right0 ; Right0 == 0 -> Left = Left0, Right = NConst ; Left0 == 0 -> Left = Const, Right = Right0 ; ( Const < 0 -> Left = Left0, Right = Right0+NConst ; Left = Left0+Const, Right = Right0 ) ). negate_coeff(A0-B, A-B) :- A is -A0. pair_product(A-B, Prod) :- Prod is A*B. compare_coeff0(Coeff-_, Compare) :- compare(Compare, Coeff, 0). scalar_plusterm([], 0). scalar_plusterm([CV|CVs], T) :- coeff_var_term(CV, T0), foldl(plusterm_, CVs, T0, T). plusterm_(CV, T0, T0+T) :- coeff_var_term(CV, T). coeff_var_term(C-V, T) :- ( C =:= 1 -> T = #V ; T = C * #V ). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Reified predicates for use with predicates from library(reif). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ clpz_t(Expr, T) :- Expr #<==> #B, zo_t(B, T). #=(X, Y, T) :- clpz_t(X #= Y, T). #<(X, Y, T) :- clpz_t(X #< Y, T). zo_t(0, false). zo_t(1, true). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Generated predicates - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ term_expansion(make_parse_clpz, Clauses) :- make_parse_clpz(Clauses). term_expansion(make_parse_reified, Clauses) :- make_parse_reified(Clauses). term_expansion(make_matches, Clauses) :- make_matches(Clauses). make_parse_clpz. make_parse_reified. make_matches. ```
Borodino () is a rural locality (a village) in Paustovskoye Rural Settlement, Vyaznikovsky District, Vladimir Oblast, Russia. The population was 14 as of 2010. Geography Borodino is located 22 km south of Vyazniki (the district's administrative centre) by road. Uspensky Pogost is the nearest rural locality. References Rural localities in Vyaznikovsky District
Of June is the first EP by American electronic music project Owl City. It was uploaded by Adam Young to his Myspace page on August 29, 2007. The EP was released digitally on December 16, 2008. Following the surprise success of Owl City's second studio album, Ocean Eyes, Of June was pressed and re-released by Universal Republic on March 30, 2010. Background Of June was recorded in July 2007. Young released the EP on MySpace which resulted in garnering an online fan base. Critical reception Of June was generally received with positive reviews. Jared Johnson of AllMusic stated, "His lyrics are poetry for a surprising number of souls who, like him, seem to have grown tired of the standard Top 40 fare." He praised the song "Hello Seattle" calling the track, "the heart of the album," whilst also remarking, "each song has elements of brilliance." Zach Hall of Jesus Freak Hideout complimented songs such as "Hello Seattle" and "Fuzzy Blue Lights". Track listing Notes "Hello Seattle" was later re-recorded and included on the band's second studio album Ocean Eyes. Charts References 2007 debut EPs Owl City albums
```rust use anyhow::Result; use turbo_tasks::{Completion, RcStr, State, Value, Vc}; use turbopack_core::introspect::{Introspectable, IntrospectableChildren}; use super::{ route_tree::{MapGetContentSourceContent, RouteTree, RouteTrees}, ContentSource, ContentSourceData, ContentSourceDataVary, ContentSourceSideEffect, GetContentSourceContent, }; use crate::source::{ContentSourceContent, ContentSources}; /// Combines two [ContentSource]s like the [CombinedContentSource], but only /// allows to serve from the second source when the first source has /// successfully served something once. /// This is a laziness optimization when the content of the second source can /// only be reached via references from the first source. /// /// For example, we use that in the content source that handles SSR rendering of /// pages. Here HTML and "other assets" are in different content sources. So we /// use this source to only serve (and process) "other assets" when the HTML was /// served once. #[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new")] pub struct ConditionalContentSource { activator: Vc<Box<dyn ContentSource>>, action: Vc<Box<dyn ContentSource>>, activated: State<bool>, } #[turbo_tasks::value_impl] impl ConditionalContentSource { #[turbo_tasks::function] pub fn new( activator: Vc<Box<dyn ContentSource>>, action: Vc<Box<dyn ContentSource>>, ) -> Vc<Self> { ConditionalContentSource { activator, action, activated: State::new(false), } .cell() } } #[turbo_tasks::value_impl] impl ContentSource for ConditionalContentSource { #[turbo_tasks::function] async fn get_routes(self: Vc<Self>) -> Result<Vc<RouteTree>> { let this = self.await?; Ok(if !*this.activated.get() { this.activator.get_routes().map_routes(Vc::upcast( ConditionalContentSourceMapper { source: self }.cell(), )) } else { Vc::<RouteTrees>::cell(vec![this.activator.get_routes(), this.action.get_routes()]) .merge() }) } #[turbo_tasks::function] fn get_children(&self) -> Vc<ContentSources> { Vc::cell(vec![self.activator, self.action]) } } #[turbo_tasks::value] struct ConditionalContentSourceMapper { source: Vc<ConditionalContentSource>, } #[turbo_tasks::value_impl] impl MapGetContentSourceContent for ConditionalContentSourceMapper { #[turbo_tasks::function] fn map_get_content( &self, get_content: Vc<Box<dyn GetContentSourceContent>>, ) -> Vc<Box<dyn GetContentSourceContent>> { Vc::upcast( ActivateOnGetContentSource { source: self.source, get_content, } .cell(), ) } } #[turbo_tasks::function] fn introspectable_type() -> Vc<RcStr> { Vc::cell("conditional content source".into()) } #[turbo_tasks::function] fn activator_key() -> Vc<RcStr> { Vc::cell("activator".into()) } #[turbo_tasks::function] fn action_key() -> Vc<RcStr> { Vc::cell("action".into()) } #[turbo_tasks::value_impl] impl Introspectable for ConditionalContentSource { #[turbo_tasks::function] fn ty(&self) -> Vc<RcStr> { introspectable_type() } #[turbo_tasks::function] async fn details(&self) -> Result<Vc<RcStr>> { Ok(Vc::cell( if *self.activated.get() { "activated" } else { "not activated" } .into(), )) } #[turbo_tasks::function] async fn title(&self) -> Result<Vc<RcStr>> { if let Some(activator) = Vc::try_resolve_sidecast::<Box<dyn Introspectable>>(self.activator).await? { Ok(activator.title()) } else { Ok(Vc::<RcStr>::default()) } } #[turbo_tasks::function] async fn children(&self) -> Result<Vc<IntrospectableChildren>> { Ok(Vc::cell( [ Vc::try_resolve_sidecast::<Box<dyn Introspectable>>(self.activator) .await? .map(|i| (activator_key(), i)), Vc::try_resolve_sidecast::<Box<dyn Introspectable>>(self.action) .await? .map(|i| (action_key(), i)), ] .into_iter() .flatten() .collect(), )) } } #[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new")] struct ActivateOnGetContentSource { source: Vc<ConditionalContentSource>, get_content: Vc<Box<dyn GetContentSourceContent>>, } #[turbo_tasks::value_impl] impl GetContentSourceContent for ActivateOnGetContentSource { #[turbo_tasks::function] fn vary(&self) -> Vc<ContentSourceDataVary> { self.get_content.vary() } #[turbo_tasks::function] async fn get( self: Vc<Self>, path: RcStr, data: Value<ContentSourceData>, ) -> Result<Vc<ContentSourceContent>> { turbo_tasks::emit(Vc::upcast::<Box<dyn ContentSourceSideEffect>>(self)); Ok(self.await?.get_content.get(path, data)) } } #[turbo_tasks::value_impl] impl ContentSourceSideEffect for ActivateOnGetContentSource { #[turbo_tasks::function] async fn apply(&self) -> Result<Vc<Completion>> { self.source.await?.activated.set(true); Ok(Completion::new()) } } ```
```php <?php /* * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the */ namespace Google\Service\DisplayVideo; class InventorySourceFilter extends \Google\Collection { protected $collection_key = 'inventorySourceIds'; /** * @var string[] */ public $inventorySourceIds; /** * @param string[] */ public function setInventorySourceIds($inventorySourceIds) { $this->inventorySourceIds = $inventorySourceIds; } /** * @return string[] */ public function getInventorySourceIds() { return $this->inventorySourceIds; } } // Adding a class alias for backwards compatibility with the previous class name. class_alias(InventorySourceFilter::class, 'Google_Service_DisplayVideo_InventorySourceFilter'); ```
```xml import { Optional, Directive, Input, Renderer2, ElementRef, Inject, forwardRef, } from '@angular/core'; import { TdLayoutComponent } from './layout.component'; import { BaseLayoutToggleDirective } from './layout-toggle.class'; @Directive({ selector: '[tdLayoutToggle]', }) export class TdLayoutToggleDirective extends BaseLayoutToggleDirective { @Input() set tdLayoutToggle(tdLayoutToggle: boolean | string) { this.disabled = !(<any>tdLayoutToggle === '' || tdLayoutToggle); } constructor( @Optional() @Inject(forwardRef(() => TdLayoutComponent)) layout: TdLayoutComponent, renderer: Renderer2, elementRef: ElementRef ) { super(layout, renderer, elementRef); } onClick(): void { this._layout.toggle(); } } @Directive({ selector: '[tdLayoutClose]', }) export class TdLayoutCloseDirective extends BaseLayoutToggleDirective { @Input() set tdLayoutClose(tdLayoutClose: boolean | string | undefined) { this.disabled = !(<any>tdLayoutClose === '' || tdLayoutClose); } constructor( @Optional() @Inject(forwardRef(() => TdLayoutComponent)) layout: TdLayoutComponent, renderer: Renderer2, elementRef: ElementRef ) { super(layout, renderer, elementRef); } onClick(): void { this._layout.close(); } } @Directive({ selector: '[tdLayoutOpen]', }) export class TdLayoutOpenDirective extends BaseLayoutToggleDirective { @Input('tdLayoutOpen') set tdLayoutClose(tdLayoutOpen: boolean) { this.disabled = !(<any>tdLayoutOpen === '' || tdLayoutOpen); } constructor( @Optional() @Inject(forwardRef(() => TdLayoutComponent)) layout: TdLayoutComponent, renderer: Renderer2, elementRef: ElementRef ) { super(layout, renderer, elementRef); } onClick(): void { this._layout.open(); } } ```
Apona plumosa is a moth in the family Eupterotidae. It was described by Frederic Moore in 1872. It is found in India. The wingspan is 94–102 mm. Adults are similar to Apona cashmirensis, but are darker red-brown. The medial line on the forewings is curved below the costa, and there are faint traces of waved lines. The postmedial line is whitish inwardly and rufous outwardly and the outer area is darker, without a waved line, the veins crossing it rufous. The hindwings have almost obsolete waved and postmedial lines and the outer area is dark, without a waved line. References Moths described in 1872 Eupterotinae
```swift // // TotpView.swift // Strongbox // // Created by Strongbox on 29/07/2024. // import Combine import SwiftUI struct TotpView: View { var totp: OTPToken @State private var totpString: String? = nil @State private var totpColor: Color = .blue @State private var animationOpacity = 1.0 #if DEBUG var previewDummyTestTimer: AnyPublisher<Date, Never> = Combine.Empty<Date, Never>(completeImmediately: false).eraseToAnyPublisher() #endif var body: some View { Text(totpString ?? "") .foregroundStyle(totpColor) .opacity(animationOpacity) .onAppear(perform: { updateTotp() }) .onReceive(NotificationCenter.default.publisher(for: .centralUpdateOtpUi, object: nil)) { _ in updateTotp() } #if DEBUG .onReceive(previewDummyTestTimer) { _ in updateTotp() } #endif } func updateTotp() { totpString = totp.codeDisplayString if let color = totp.color { #if os(iOS) totpColor = Color(uiColor: color) #else totpColor = Color(nsColor: color) #endif } else { totpColor = .blue } if totp.remainingSeconds < 10 { withAnimation(.easeOut(duration: 0.65).repeatForever()) { animationOpacity = 0.35 } } else { withAnimation { animationOpacity = 1 } } } } #if DEBUG #Preview { var timer = Timer.publish(every: 1, tolerance: 0.5, on: .main, in: .common) .autoconnect() .eraseToAnyPublisher() return TotpView(totp: OTPToken(url: URL(string: "otpauth: } #endif ```
The Macrocephali ("large headed") were an ancient tribe of Africans or Indians who performed artificial cranial deformation. Their cultural practice of artificially shaping the skulls of their children was mentioned by Hesiod, Hippocrates, Pomponius Mela, Pliny the Elder, Valerius Flaccus, Xenophon, Strabo, and Eustathius. References Greek legendary creatures Mythic humanoids
```java // This source code is licensed under both the GPLv2 (found in the // (found in the LICENSE.Apache file in the root directory). package org.rocksdb; import java.util.*; public class MutableColumnFamilyOptions extends AbstractMutableOptions { /** * User must use builder pattern, or parser. * * @param keys the keys * @param values the values * * See {@link #builder()} and {@link #parse(String)}. */ private MutableColumnFamilyOptions(final String[] keys, final String[] values) { super(keys, values); } /** * Creates a builder which allows you * to set MutableColumnFamilyOptions in a fluent * manner * * @return A builder for MutableColumnFamilyOptions */ public static MutableColumnFamilyOptionsBuilder builder() { return new MutableColumnFamilyOptionsBuilder(); } /** * Parses a String representation of MutableColumnFamilyOptions * * The format is: key1=value1;key2=value2;key3=value3 etc * * For int[] values, each int should be separated by a comma, e.g. * * key1=value1;intArrayKey1=1,2,3 * * @param str The string representation of the mutable column family options * * @return A builder for the mutable column family options */ public static MutableColumnFamilyOptionsBuilder parse(final String str) { Objects.requireNonNull(str); final MutableColumnFamilyOptionsBuilder builder = new MutableColumnFamilyOptionsBuilder(); final String[] options = str.trim().split(KEY_VALUE_PAIR_SEPARATOR); for(final String option : options) { final int equalsOffset = option.indexOf(KEY_VALUE_SEPARATOR); if(equalsOffset <= 0) { throw new IllegalArgumentException( "options string has an invalid key=value pair"); } final String key = option.substring(0, equalsOffset); if(key.isEmpty()) { throw new IllegalArgumentException("options string is invalid"); } final String value = option.substring(equalsOffset + 1); if(value.isEmpty()) { throw new IllegalArgumentException("options string is invalid"); } builder.fromString(key, value); } return builder; } private interface MutableColumnFamilyOptionKey extends MutableOptionKey {} public enum MemtableOption implements MutableColumnFamilyOptionKey { write_buffer_size(ValueType.LONG), arena_block_size(ValueType.LONG), memtable_prefix_bloom_size_ratio(ValueType.DOUBLE), @Deprecated memtable_prefix_bloom_bits(ValueType.INT), @Deprecated memtable_prefix_bloom_probes(ValueType.INT), memtable_huge_page_size(ValueType.LONG), max_successive_merges(ValueType.LONG), @Deprecated filter_deletes(ValueType.BOOLEAN), max_write_buffer_number(ValueType.INT), inplace_update_num_locks(ValueType.LONG); private final ValueType valueType; MemtableOption(final ValueType valueType) { this.valueType = valueType; } @Override public ValueType getValueType() { return valueType; } } public enum CompactionOption implements MutableColumnFamilyOptionKey { disable_auto_compactions(ValueType.BOOLEAN), @Deprecated soft_rate_limit(ValueType.DOUBLE), soft_pending_compaction_bytes_limit(ValueType.LONG), @Deprecated hard_rate_limit(ValueType.DOUBLE), hard_pending_compaction_bytes_limit(ValueType.LONG), level0_file_num_compaction_trigger(ValueType.INT), level0_slowdown_writes_trigger(ValueType.INT), level0_stop_writes_trigger(ValueType.INT), max_compaction_bytes(ValueType.LONG), target_file_size_base(ValueType.LONG), target_file_size_multiplier(ValueType.INT), max_bytes_for_level_base(ValueType.LONG), max_bytes_for_level_multiplier(ValueType.INT), max_bytes_for_level_multiplier_additional(ValueType.INT_ARRAY), ttl(ValueType.LONG); private final ValueType valueType; CompactionOption(final ValueType valueType) { this.valueType = valueType; } @Override public ValueType getValueType() { return valueType; } } public enum MiscOption implements MutableColumnFamilyOptionKey { max_sequential_skip_in_iterations(ValueType.LONG), paranoid_file_checks(ValueType.BOOLEAN), report_bg_io_stats(ValueType.BOOLEAN), compression_type(ValueType.ENUM); private final ValueType valueType; MiscOption(final ValueType valueType) { this.valueType = valueType; } @Override public ValueType getValueType() { return valueType; } } public static class MutableColumnFamilyOptionsBuilder extends AbstractMutableOptionsBuilder<MutableColumnFamilyOptions, MutableColumnFamilyOptionsBuilder, MutableColumnFamilyOptionKey> implements MutableColumnFamilyOptionsInterface<MutableColumnFamilyOptionsBuilder> { private final static Map<String, MutableColumnFamilyOptionKey> ALL_KEYS_LOOKUP = new HashMap<>(); static { for(final MutableColumnFamilyOptionKey key : MemtableOption.values()) { ALL_KEYS_LOOKUP.put(key.name(), key); } for(final MutableColumnFamilyOptionKey key : CompactionOption.values()) { ALL_KEYS_LOOKUP.put(key.name(), key); } for(final MutableColumnFamilyOptionKey key : MiscOption.values()) { ALL_KEYS_LOOKUP.put(key.name(), key); } } private MutableColumnFamilyOptionsBuilder() { super(); } @Override protected MutableColumnFamilyOptionsBuilder self() { return this; } @Override protected Map<String, MutableColumnFamilyOptionKey> allKeys() { return ALL_KEYS_LOOKUP; } @Override protected MutableColumnFamilyOptions build(final String[] keys, final String[] values) { return new MutableColumnFamilyOptions(keys, values); } @Override public MutableColumnFamilyOptionsBuilder setWriteBufferSize( final long writeBufferSize) { return setLong(MemtableOption.write_buffer_size, writeBufferSize); } @Override public long writeBufferSize() { return getLong(MemtableOption.write_buffer_size); } @Override public MutableColumnFamilyOptionsBuilder setArenaBlockSize( final long arenaBlockSize) { return setLong(MemtableOption.arena_block_size, arenaBlockSize); } @Override public long arenaBlockSize() { return getLong(MemtableOption.arena_block_size); } @Override public MutableColumnFamilyOptionsBuilder setMemtablePrefixBloomSizeRatio( final double memtablePrefixBloomSizeRatio) { return setDouble(MemtableOption.memtable_prefix_bloom_size_ratio, memtablePrefixBloomSizeRatio); } @Override public double memtablePrefixBloomSizeRatio() { return getDouble(MemtableOption.memtable_prefix_bloom_size_ratio); } @Override public MutableColumnFamilyOptionsBuilder setMemtableHugePageSize( final long memtableHugePageSize) { return setLong(MemtableOption.memtable_huge_page_size, memtableHugePageSize); } @Override public long memtableHugePageSize() { return getLong(MemtableOption.memtable_huge_page_size); } @Override public MutableColumnFamilyOptionsBuilder setMaxSuccessiveMerges( final long maxSuccessiveMerges) { return setLong(MemtableOption.max_successive_merges, maxSuccessiveMerges); } @Override public long maxSuccessiveMerges() { return getLong(MemtableOption.max_successive_merges); } @Override public MutableColumnFamilyOptionsBuilder setMaxWriteBufferNumber( final int maxWriteBufferNumber) { return setInt(MemtableOption.max_write_buffer_number, maxWriteBufferNumber); } @Override public int maxWriteBufferNumber() { return getInt(MemtableOption.max_write_buffer_number); } @Override public MutableColumnFamilyOptionsBuilder setInplaceUpdateNumLocks( final long inplaceUpdateNumLocks) { return setLong(MemtableOption.inplace_update_num_locks, inplaceUpdateNumLocks); } @Override public long inplaceUpdateNumLocks() { return getLong(MemtableOption.inplace_update_num_locks); } @Override public MutableColumnFamilyOptionsBuilder setDisableAutoCompactions( final boolean disableAutoCompactions) { return setBoolean(CompactionOption.disable_auto_compactions, disableAutoCompactions); } @Override public boolean disableAutoCompactions() { return getBoolean(CompactionOption.disable_auto_compactions); } @Override public MutableColumnFamilyOptionsBuilder setSoftPendingCompactionBytesLimit( final long softPendingCompactionBytesLimit) { return setLong(CompactionOption.soft_pending_compaction_bytes_limit, softPendingCompactionBytesLimit); } @Override public long softPendingCompactionBytesLimit() { return getLong(CompactionOption.soft_pending_compaction_bytes_limit); } @Override public MutableColumnFamilyOptionsBuilder setHardPendingCompactionBytesLimit( final long hardPendingCompactionBytesLimit) { return setLong(CompactionOption.hard_pending_compaction_bytes_limit, hardPendingCompactionBytesLimit); } @Override public long hardPendingCompactionBytesLimit() { return getLong(CompactionOption.hard_pending_compaction_bytes_limit); } @Override public MutableColumnFamilyOptionsBuilder setLevel0FileNumCompactionTrigger( final int level0FileNumCompactionTrigger) { return setInt(CompactionOption.level0_file_num_compaction_trigger, level0FileNumCompactionTrigger); } @Override public int level0FileNumCompactionTrigger() { return getInt(CompactionOption.level0_file_num_compaction_trigger); } @Override public MutableColumnFamilyOptionsBuilder setLevel0SlowdownWritesTrigger( final int level0SlowdownWritesTrigger) { return setInt(CompactionOption.level0_slowdown_writes_trigger, level0SlowdownWritesTrigger); } @Override public int level0SlowdownWritesTrigger() { return getInt(CompactionOption.level0_slowdown_writes_trigger); } @Override public MutableColumnFamilyOptionsBuilder setLevel0StopWritesTrigger( final int level0StopWritesTrigger) { return setInt(CompactionOption.level0_stop_writes_trigger, level0StopWritesTrigger); } @Override public int level0StopWritesTrigger() { return getInt(CompactionOption.level0_stop_writes_trigger); } @Override public MutableColumnFamilyOptionsBuilder setMaxCompactionBytes(final long maxCompactionBytes) { return setLong(CompactionOption.max_compaction_bytes, maxCompactionBytes); } @Override public long maxCompactionBytes() { return getLong(CompactionOption.max_compaction_bytes); } @Override public MutableColumnFamilyOptionsBuilder setTargetFileSizeBase( final long targetFileSizeBase) { return setLong(CompactionOption.target_file_size_base, targetFileSizeBase); } @Override public long targetFileSizeBase() { return getLong(CompactionOption.target_file_size_base); } @Override public MutableColumnFamilyOptionsBuilder setTargetFileSizeMultiplier( final int targetFileSizeMultiplier) { return setInt(CompactionOption.target_file_size_multiplier, targetFileSizeMultiplier); } @Override public int targetFileSizeMultiplier() { return getInt(CompactionOption.target_file_size_multiplier); } @Override public MutableColumnFamilyOptionsBuilder setMaxBytesForLevelBase( final long maxBytesForLevelBase) { return setLong(CompactionOption.max_bytes_for_level_base, maxBytesForLevelBase); } @Override public long maxBytesForLevelBase() { return getLong(CompactionOption.max_bytes_for_level_base); } @Override public MutableColumnFamilyOptionsBuilder setMaxBytesForLevelMultiplier( final double maxBytesForLevelMultiplier) { return setDouble(CompactionOption.max_bytes_for_level_multiplier, maxBytesForLevelMultiplier); } @Override public double maxBytesForLevelMultiplier() { return getDouble(CompactionOption.max_bytes_for_level_multiplier); } @Override public MutableColumnFamilyOptionsBuilder setMaxBytesForLevelMultiplierAdditional( final int[] maxBytesForLevelMultiplierAdditional) { return setIntArray( CompactionOption.max_bytes_for_level_multiplier_additional, maxBytesForLevelMultiplierAdditional); } @Override public int[] maxBytesForLevelMultiplierAdditional() { return getIntArray( CompactionOption.max_bytes_for_level_multiplier_additional); } @Override public MutableColumnFamilyOptionsBuilder setMaxSequentialSkipInIterations( final long maxSequentialSkipInIterations) { return setLong(MiscOption.max_sequential_skip_in_iterations, maxSequentialSkipInIterations); } @Override public long maxSequentialSkipInIterations() { return getLong(MiscOption.max_sequential_skip_in_iterations); } @Override public MutableColumnFamilyOptionsBuilder setParanoidFileChecks( final boolean paranoidFileChecks) { return setBoolean(MiscOption.paranoid_file_checks, paranoidFileChecks); } @Override public boolean paranoidFileChecks() { return getBoolean(MiscOption.paranoid_file_checks); } @Override public MutableColumnFamilyOptionsBuilder setCompressionType( final CompressionType compressionType) { return setEnum(MiscOption.compression_type, compressionType); } @Override public CompressionType compressionType() { return (CompressionType)getEnum(MiscOption.compression_type); } @Override public MutableColumnFamilyOptionsBuilder setReportBgIoStats( final boolean reportBgIoStats) { return setBoolean(MiscOption.report_bg_io_stats, reportBgIoStats); } @Override public boolean reportBgIoStats() { return getBoolean(MiscOption.report_bg_io_stats); } @Override public MutableColumnFamilyOptionsBuilder setTtl(final long ttl) { return setLong(CompactionOption.ttl, ttl); } @Override public long ttl() { return getLong(CompactionOption.ttl); } } } ```
Chori Chori is a 2003 Indian Hindi-language romantic comedy-drama film directed by Milan Luthria. It stars Ajay Devgn and Rani Mukerji in the lead roles. It is not related to the 1956 Hindi film of the same name. It is inspired by the Hollywood film Housesitter (1992). Plot Khushi (Rani Mukerji) is a happy-go-lucky orphan living in Delhi. She meets Ranbir Malhotra (Ajay Devgn) through a chance encounter one day before she is fired from her job. He tells her about a dream house that he has built in Shimla. After being dismissed from her job, she locates the bungalow and moves in, informing everyone that she is Ranbir's fiancée. There she meets Ranbir's family and Pooja (Sonali Bendre), Ranbir's love. When Ranbir returns, at first he is outraged at Khushi's intrusion in his life but then decides to play along with her to make Pooja jealous and fall in love with him. Khushi and Ranbir end up falling in love. However, Khushi's close encounter with reality and Ranbir's old commitments hold them back for a long time before they finally listen to their hearts. Cast Ajay Devgn as Ranbir Malhotra Rani Mukerji as Khushi Sonali Bendre as Pooja Kamini Kaushal as Beeji Tiku Talsania as Chachaji Smita Jaykar as Mrs. Malhotra Sadashiv Amrapurkar as Chacha Shashikala as Chachi Satish Shah Soundtrack Music was composed by duo Sajid–Wajid, while lyrics were penned by Anand Bakshi. References External links 2000s Hindi-language films 2003 films Films directed by Milan Luthria Films scored by Sajid–Wajid
```c /* * */ #define DT_DRV_COMPAT ti_tmp108 #include <zephyr/device.h> #include <zephyr/drivers/i2c.h> #include <zephyr/drivers/sensor.h> #include <zephyr/sys/util.h> #include <zephyr/sys/byteorder.h> #include <zephyr/logging/log.h> #include <zephyr/kernel.h> #include "tmp108.h" LOG_MODULE_REGISTER(TMP108, CONFIG_SENSOR_LOG_LEVEL); int tmp108_reg_read(const struct device *dev, uint8_t reg, uint16_t *val) { const struct tmp108_config *cfg = dev->config; int result; result = i2c_burst_read_dt(&cfg->i2c_spec, reg, (uint8_t *) val, 2); if (result < 0) { return result; } *val = sys_be16_to_cpu(*val); return 0; } int tmp108_reg_write(const struct device *dev, uint8_t reg, uint16_t val) { const struct tmp108_config *cfg = dev->config; uint8_t tx_buf[3]; int result; tx_buf[0] = reg; sys_put_be16(val, &tx_buf[1]); result = i2c_write_dt(&cfg->i2c_spec, tx_buf, sizeof(tx_buf)); if (result < 0) { return result; } return 0; } int tmp108_write_config(const struct device *dev, uint16_t mask, uint16_t conf) { uint16_t config = 0; int result; result = tmp108_reg_read(dev, TI_TMP108_REG_CONF, &config); if (result < 0) { return result; } config &= mask; config |= conf; result = tmp108_reg_write(dev, TI_TMP108_REG_CONF, config); if (result < 0) { return result; } return 0; } int ti_tmp108_read_temp(const struct device *dev) { struct tmp108_data *drv_data = dev->data; int result; /* clear previous temperature readings */ drv_data->sample = 0U; /* Get the most recent temperature measurement */ result = tmp108_reg_read(dev, TI_TMP108_REG_TEMP, &drv_data->sample); if (result < 0) { return result; } return 0; } static int tmp108_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct tmp108_data *drv_data = dev->data; int result; if (chan != SENSOR_CHAN_ALL && chan != SENSOR_CHAN_AMBIENT_TEMP) { return -ENOTSUP; } /* If one shot mode is set, query chip for reading * should be finished 30 ms later */ if (drv_data->one_shot_mode == true) { result = tmp108_write_config(dev, TI_TMP108_MODE_MASK(dev), TI_TMP108_MODE_ONE_SHOT(dev)); if (result < 0) { return result; } /* Schedule read to start in 30 ms if mode change was successful * the typical wakeup time given in the data sheet is 27 */ result = k_work_schedule(&drv_data->scheduled_work, K_MSEC(TMP108_WAKEUP_TIME_IN_MS(dev))); if (result < 0) { return result; } return 0; } result = ti_tmp108_read_temp(dev); if (result < 0) { return result; } return 0; } static int tmp108_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { struct tmp108_data *drv_data = dev->data; int32_t uval; if (chan != SENSOR_CHAN_AMBIENT_TEMP) { return -ENOTSUP; } uval = ((int32_t)drv_data->sample * TMP108_TEMP_MULTIPLIER(dev)) / TMP108_TEMP_DIVISOR(dev); val->val1 = uval / 1000000; val->val2 = uval % 1000000; return 0; } static int tmp108_attr_get(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val) { int result; uint16_t tmp_val; if (chan != SENSOR_CHAN_AMBIENT_TEMP && chan != SENSOR_CHAN_ALL) { return -ENOTSUP; } switch ((int) attr) { case SENSOR_ATTR_CONFIGURATION: result = tmp108_reg_read(dev, TI_TMP108_REG_CONF, &tmp_val); val->val1 = tmp_val; val->val2 = 0; break; default: return -ENOTSUP; } return result; } static int tmp108_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { struct tmp108_data *drv_data = dev->data; uint16_t mode = 0; uint16_t reg_value = 0; int result = 0; int32_t uval; if (chan != SENSOR_CHAN_AMBIENT_TEMP && chan != SENSOR_CHAN_ALL) { return -ENOTSUP; } switch ((int) attr) { case SENSOR_ATTR_HYSTERESIS: if (TI_TMP108_HYSTER_0_C(dev) == TI_TMP108_CONF_NA) { LOG_WRN("AS621x Series lacks Hysterisis setttings"); return -ENOTSUP; } if (val->val1 < 1) { mode = TI_TMP108_HYSTER_0_C(dev); } else if (val->val1 < 2) { mode = TI_TMP108_HYSTER_1_C(dev); } else if (val->val1 < 4) { mode = TI_TMP108_HYSTER_2_C(dev); } else { mode = TI_TMP108_HYSTER_4_C(dev); } result = tmp108_write_config(dev, TI_TMP108_HYSTER_MASK(dev), mode); break; case SENSOR_ATTR_ALERT: /* Spec Sheet Errata: TM is set on reset not cleared */ if (val->val1 == 1) { mode = TI_TMP108_CONF_TM_INT(dev); } else { mode = TI_TMP108_CONF_TM_CMP(dev); } result = tmp108_write_config(dev, TI_TMP108_CONF_TM_MASK(dev), mode); break; case SENSOR_ATTR_LOWER_THRESH: uval = val->val1 * 1000000 + val->val2; reg_value = (uval * TMP108_TEMP_DIVISOR(dev)) / TMP108_TEMP_MULTIPLIER(dev); result = tmp108_reg_write(dev, TI_TMP108_REG_LOW_LIMIT, reg_value); break; case SENSOR_ATTR_UPPER_THRESH: uval = val->val1 * 1000000 + val->val2; reg_value = (uval * TMP108_TEMP_DIVISOR(dev)) / TMP108_TEMP_MULTIPLIER(dev); result = tmp108_reg_write(dev, TI_TMP108_REG_HIGH_LIMIT, reg_value); break; case SENSOR_ATTR_SAMPLING_FREQUENCY: if (val->val1 < 1) { mode = TI_TMP108_FREQ_4_SECS(dev); } else if (val->val1 < 4) { mode = TI_TMP108_FREQ_1_HZ(dev); } else if (val->val1 < 16) { mode = TI_TMP108_FREQ_4_HZ(dev); } else { mode = TI_TMP108_FREQ_16_HZ(dev); } result = tmp108_write_config(dev, TI_TMP108_FREQ_MASK(dev), mode); break; case SENSOR_ATTR_TMP108_SHUTDOWN_MODE: result = tmp108_write_config(dev, TI_TMP108_MODE_MASK(dev), TI_TMP108_MODE_SHUTDOWN(dev)); drv_data->one_shot_mode = false; break; case SENSOR_ATTR_TMP108_CONTINUOUS_CONVERSION_MODE: result = tmp108_write_config(dev, TI_TMP108_MODE_MASK(dev), TI_TMP108_MODE_CONTINUOUS(dev)); drv_data->one_shot_mode = false; break; case SENSOR_ATTR_TMP108_ONE_SHOT_MODE: result = tmp108_write_config(dev, TI_TMP108_MODE_MASK(dev), TI_TMP108_MODE_ONE_SHOT(dev)); drv_data->one_shot_mode = true; break; case SENSOR_ATTR_TMP108_ALERT_POLARITY: if (val->val1 == 1) { mode = TI_TMP108_CONF_POL_HIGH(dev); } else { mode = TI_TMP108_CONF_POL_LOW(dev); } result = tmp108_write_config(dev, TI_TMP108_CONF_POL_MASK(dev), mode); break; default: return -ENOTSUP; } if (result < 0) { return result; } return 0; } static const struct sensor_driver_api tmp108_driver_api = { .attr_set = tmp108_attr_set, .attr_get = tmp108_attr_get, .sample_fetch = tmp108_sample_fetch, .channel_get = tmp108_channel_get, .trigger_set = tmp_108_trigger_set, }; #ifdef CONFIG_TMP108_ALERT_INTERRUPTS static int setup_interrupts(const struct device *dev) { struct tmp108_data *drv_data = dev->data; const struct tmp108_config *config = dev->config; const struct gpio_dt_spec *alert_gpio = &config->alert_gpio; int result; if (!device_is_ready(alert_gpio->port)) { LOG_ERR("tmp108: gpio controller %s not ready", alert_gpio->port->name); return -ENODEV; } result = gpio_pin_configure_dt(alert_gpio, GPIO_INPUT); if (result < 0) { return result; } gpio_init_callback(&drv_data->temp_alert_gpio_cb, tmp108_trigger_handle_alert, BIT(alert_gpio->pin)); result = gpio_add_callback(alert_gpio->port, &drv_data->temp_alert_gpio_cb); if (result < 0) { return result; } result = gpio_pin_interrupt_configure_dt(alert_gpio, GPIO_INT_EDGE_BOTH); if (result < 0) { return result; } return 0; } #endif static int tmp108_init(const struct device *dev) { const struct tmp108_config *cfg = dev->config; struct tmp108_data *drv_data = dev->data; int result = 0; if (!device_is_ready(cfg->i2c_spec.bus)) { LOG_ERR("I2C dev %s not ready", cfg->i2c_spec.bus->name); return -ENODEV; } drv_data->scheduled_work.work.handler = tmp108_trigger_handle_one_shot; /* save this driver instance for passing to other functions */ drv_data->tmp108_dev = dev; #ifdef CONFIG_TMP108_ALERT_INTERRUPTS result = setup_interrupts(dev); if (result < 0) { return result; } #endif /* clear and set configuration registers back to default values */ result = tmp108_write_config(dev, 0x0000, TMP108_CONF_RST(dev)); return result; } #define TMP108_DEFINE(inst, t) \ static struct tmp108_data tmp108_prv_data_##inst##t; \ static const struct tmp108_config tmp108_config_##inst##t = { \ .i2c_spec = I2C_DT_SPEC_INST_GET(inst), \ .alert_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, \ alert_gpios, { 0 }),\ .reg_def = t##_CONF \ }; \ SENSOR_DEVICE_DT_INST_DEFINE(inst, \ &tmp108_init, \ NULL, \ &tmp108_prv_data_##inst##t, \ &tmp108_config_##inst##t, \ POST_KERNEL, \ CONFIG_SENSOR_INIT_PRIORITY, \ &tmp108_driver_api); #define TMP108_INIT(n) TMP108_DEFINE(n, TI_TMP108) #undef DT_DRV_COMPAT #define DT_DRV_COMPAT ti_tmp108 DT_INST_FOREACH_STATUS_OKAY(TMP108_INIT) #define AS6212_INIT(n) TMP108_DEFINE(n, AMS_AS6212) #undef DT_DRV_COMPAT #define DT_DRV_COMPAT ams_as6212 DT_INST_FOREACH_STATUS_OKAY(AS6212_INIT) ```
```javascript Weak vs Strict equality operator Deleting properties Labeling your loops Closures Extra function arguments are undefined by default ```
Asatiani () is a Georgian surname that may refer to: Kakhi Asatiani (1947–2002), Soviet footballer and manager Lado Asatiani (1917–1943), Soviet poet Maia Asatiani (born 1977), Georgian TV host Malkhaz Asatiani (born 1981), Georgian footballer Mikheil Asatiani (1882–1938), Georgian psychiatrist Nugzar Asatiani (1937–1992), Soviet fencer Tina Asatiani (1918–2011), Armenian physicist Georgian-language surnames
```java /* * * * path_to_url * * Unless required by applicable law or agreed to in writing, * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * specific language governing permissions and limitations */ package io.ballerina.semantic.api.test.typebynode.newapi; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeVisitor; import io.ballerina.compiler.syntax.tree.TypeCastExpressionNode; import io.ballerina.compiler.syntax.tree.TypeTestExpressionNode; import io.ballerina.compiler.syntax.tree.TypeofExpressionNode; import org.testng.annotations.Test; import java.util.Optional; import static io.ballerina.compiler.api.symbols.TypeDescKind.BOOLEAN; import static io.ballerina.compiler.api.symbols.TypeDescKind.STRING; import static io.ballerina.compiler.api.symbols.TypeDescKind.TYPEDESC; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; /** * Tests for getting the type of typeof and type cast exprs. * * @since 2.0.0 */ @Test public class TypeByTypeExprTest extends TypeByNodeTest { @Override String getTestSourcePath() { return "test-src/type-by-node/type_by_type_exprs.bal"; } @Override NodeVisitor getNodeVisitor(SemanticModel model) { return new NodeVisitor() { @Override public void visit(TypeCastExpressionNode typeCastExpressionNode) { assertType(typeCastExpressionNode, model, STRING); } @Override public void visit(TypeofExpressionNode typeofExpressionNode) { assertType(typeofExpressionNode, model, TYPEDESC); } @Override public void visit(TypeTestExpressionNode typeTestExpressionNode) { assertType(typeTestExpressionNode, model, BOOLEAN); } }; } void verifyAssertCount() { assertEquals(getAssertCount(), 3); } private Optional<TypeSymbol> assertType(Node node, SemanticModel model, TypeDescKind typeKind) { Optional<TypeSymbol> type = model.typeOf(node); assertTrue(type.isPresent()); assertEquals(type.get().typeKind(), typeKind); incrementAssertCount(); return type; } } ```
The Togavirus 5′ plus strand cis-regulatory element is an RNA element which is thought to be essential for both plus and minus strand RNA synthesis. Genus Alphavirus belongs to the family Togaviridae. Alpha viruses contain secondary structural motifs in the 5′ UTR that allow them to avoid detection by IFIT1. See also Rubella virus 3′ cis-acting element References External links Cis-regulatory RNA elements
```cmake vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO Atliac/minitest REF "v${VERSION}" SHA512 your_sha256_hashyour_sha256_hash HEAD_REF master ) vcpkg_cmake_configure(SOURCE_PATH ${SOURCE_PATH} OPTIONS -DBUILD_TESTS=OFF -DMINITEST_PACKAGE_NAME=${PORT} ) vcpkg_cmake_install() vcpkg_cmake_config_fixup() configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage") vcpkg_copy_pdbs() vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") ```
Městský fotbalový stadion Miroslava Valenty is a multi-use stadium in Uherské Hradiště, Czech Republic. It is used mostly for football matches and is the home ground of 1. FC Slovácko. The stadium has an all-seated capacity of 8,121 people. The first match to take place at the stadium was a friendly match on 12 October 2003, with Slovácko hosting German side Borussia Mönchengladbach. The hosts won 3–2. During the 2003–04 Czech First League, Synot played their home games for the first part of the season at Brno and Drnovice. Their first home league match at the stadium was on 18 October 2003 against Olomouc. In August 2009, it was announced that the stadium would be renamed Městský fotbalový stadion Miroslava Valenty after the 2008 death of benefactor Miroslav Valenta. International matches Městský fotbalový stadion Miroslava Valenty has hosted three full internationals of the Czech national team. References External links Photo gallery and data at Erlebnis-stadion.de Football venues in the Czech Republic Czech First League venues 1. FC Slovácko Buildings and structures in the Zlín Region Sports venues completed in 2003 2003 establishments in the Czech Republic 21st-century architecture in the Czech Republic
The Breitlingsee, or Breitling See, is a lake in the state of Brandenburg, Germany. It is situated to the west of the city of Brandenburg an der Havel, and is one of a number of directly linked lakes, along with the Möserscher See, Plauer See, Quenzsee and Wendsee. The lake has a surface area of . The navigable River Havel flows through the lake, entering from the east and exiting directly into the Plauer See. Navigation is administered as part of the Untere Havel–Wasserstraße. References External links Lakes of Brandenburg Federal waterways in Germany LBreitlingsee
The 1984 USA Outdoor Track and Field Championships took place between June 8–9 at Jaguar Stadium on the campus of San Jose City College in San Jose, California. The meet was organized by The Athletics Congress. This meet was separate from the 1984 Olympic Trials, held in the Los Angeles Memorial Coliseum a week later. Among the notable events at this meet were Leslie Maxie's youth world best in the 400 metres hurdles that lasted more than 30 years. Also, then 47 year old Al Oerter was at this meet making one last attempt to get to the Olympics, 16 years after the end of his 4 successive gold medal streak in the discus. His hopes ended here when he was injured stepping into a crater left by a hammer during the preliminary round. Local rivals John Powell and Mac Wilkins instead threw their season bests at this meet before going on to the silver (Wilkins) and bronze (Powell) medals at the Olympics in Los Angeles. Results Men track events Men field events Women track events Women field events See also United States Olympic Trials (track and field) References External links results USA Outdoor Track and Field Championships Usa Outdoor Track And Field Championships, 1984 Track and field Track and field in California Outdoor Track and Field Championships Outdoor Track and Field Championships Sports competitions in California
The Ma Tante River is a tributary of the Franquelin River, flowing in the township of Franquelin, in the municipality of Franquelin, in the Manicouagan Regional County Municipality, in the administrative region of Côte-Nord, in the province of Quebec, in Canada. Forestry is the main economic activity in this valley; recreational tourism, second. The surface of this Middle North Shore river is usually frozen from the beginning of November to the end of April, except the rapids; however, safe circulation on the ice is generally from late November to early April. Geography The Ma Tante river takes its source from "Ma Tante lake" (length: ; altitude: ) located in the municipality of Franquelin. This mouth is located at northeast of the mouth of the Ma Tante River. From its source, the Ma Tante river flows over with a drop of , in the forest zone, according to the following segments: first towards the east crossing a little lake (altitude: ) on ; by collecting the discharge of two lakes including Lac à Duncan, then towards the south, until the discharge of a stream (coming from the northwest); to the south in a slightly deep valley, to the outlet (coming from the east) of three lakes including Lac Gauthier; first towards the west up to a river elbow corresponding to the discharge of a stream (coming from north), toward south by crossing a small area of marshland, then towards the southwest by crossing a small lake, to its mouth. The Ma Tante river flows into a bend on the east bank of the Franquelin river. This confluence is located at: north of the mouth of the Franquelin River; west of the village center of Godbout; north-east of downtown Baie-Comeau. From the mouth of the Ma Tante river, the current descends on the course of the Franquelin river to the north shore of the estuary of Saint Lawrence. Toponymy The acronym "rivière Ma Tante" was attributed to this watercourse in association with the acronym "rivière Mon Oncle" (watercourse located further east) evoking Raymond Côté's uncle, a worker forest. The toponym "Ma Tante River" appears on a 1933 map of the Ontario Paper Company. The toponym "Ma Tante river" was formalized on August 2, 1974, at the Place Names Bank of the Commission de toponymie du Québec. See also Gulf of St. Lawrence List of rivers of Quebec References Rivers of Côte-Nord Manicouagan Regional County Municipality
```javascript /** * @license Apache-2.0 * * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ 'use strict'; /** * Test if a value is typed-array-like. * * @module @stdlib/assert/is-typed-array-like * * @example * var Int16Array = require( '@stdlib/array/int16' ); * var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); * * var bool = isTypedArrayLike( new Int16Array() ); * // returns true * * bool = isTypedArrayLike({ * 'length': 10, * 'byteOffset': 0, * 'byteLength': 10, * 'BYTES_PER_ELEMENT': 4 * }); * // returns true */ // MODULES // var main = require( './main.js' ); // EXPORTS // module.exports = main; ```
```c++ #include "test_threads.h" #include <future> #include <functional> #include <chrono> using namespace std::chrono_literals; int main(int argc, char** argv) { int rc = test_threads(); return rc; } ```
```javascript tinymce.PluginManager.add("wpview",function(a){function b(a){return c(a,"wpview-wrap")}function c(a,b){for(;a&&a.parentNode;){if(a.className&&-1!==(" "+a.className+" ").indexOf(" "+b+" "))return a;a=a.parentNode}return!1}function d(a){a.stopPropagation()}function e(b,c){var d=b?"before":"after",e=b?0:1;i(),a.selection.setCursorLocation(a.dom.select(".wpview-selection-"+d,c)[0],e),a.nodeChanged()}function f(b,c,d){var f=a.dom,g=f.create("p");w.ie&&w.ie<11||(g.innerHTML='<br data-mce-bogus="1">'),c?b.parentNode.insertBefore(g,b):f.insertAfter(g,b),i(),c&&d===x.ENTER?e(c,b):a.selection.setCursorLocation(g,0),a.nodeChanged()}function g(b){a.undoManager.transact(function(){f(b),wp.mce.views.remove(a,b)})}function h(b){var c,e=a.dom;b&&(b!==n&&(a.getBody().focus(),i(),n=b,e.setAttrib(b,"data-mce-selected",1),c=e.create("div",{"class":"wpview-clipboard",contenteditable:"true"},wp.mce.views.getText(b)),a.dom.select(".wpview-body",b)[0].appendChild(c),e.bind(c,"beforedeactivate focusin focusout",d),e.bind(n,"beforedeactivate focusin focusout",d),C?a.selection.select(c):a.selection.select(c,!0)),a.nodeChanged(),a.fire("wpview-selected",b))}function i(){var b,c=a.dom;n&&(b=a.dom.select(".wpview-clipboard",n)[0],c.unbind(b),c.remove(b),c.unbind(n,"beforedeactivate focusin focusout click mouseup",d),c.setAttrib(n,"data-mce-selected",null)),n=null}function j(a,b){return"<p>"+window.decodeURIComponent(b)+"</p>"}function k(a){return a.replace(/<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*|\.)<\/div>/g,j).replace(/<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,j)}function l(a){v("div[data-wpview-text], p[data-wpview-marker]",a).each(function(a,b){b.innerHTML="."})}function m(a){return 47>=a&&a!==x.SPACEBAR&&a!==x.ENTER&&a!==x.DELETE&&a!==x.BACKSPACE&&(37>a||a>40)||a>=224||a>=144&&150>=a||a>=91&&93>=a||a>=112&&135>=a}var n,o,p,q,r,s,t,u,v=a.$,w=tinymce.Env,x=tinymce.util.VK,y=tinymce.dom.TreeWalker,z=!1,A=!0,B=function(){return!1},C=/iPad|iPod|iPhone/.test(navigator.userAgent);return"undefined"!=typeof wp&&wp.mce?(a.on("BeforeAddUndo",function(a){a.level.content&&(a.level.content=k(a.level.content))}),a.on("BeforeSetContent",function(b){var c;if(b.selection||wp.mce.views.unbind(),b.content){if(!b.load&&(n&&g(n),c=a.selection.getNode(),c&&c!==a.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(b.content))){if(c=a.dom.getParent(c,"p"),!c||!/^[\s\uFEFF\u00A0]*$/.test(v(c).text()||""))return;c.innerHTML=""}b.content=wp.mce.views.setMarkers(b.content)}}),a.on("pastePreProcess",function(a){var b=a.content;b&&(b=tinymce.trim(b.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(b)&&(a.content=b))}),a.on("SetContent",function(){wp.mce.views.render()}),a.on("click",function(c){var d,f,g,h=c.clientX,i=c.clientY,j=a.getBody(),k=j.getBoundingClientRect(),l=j.firstChild,m=j.lastChild;l&&m&&(d=l.getBoundingClientRect(),f=m.getBoundingClientRect(),i<d.top&&(g=b(l))?(e(!0,g),c.preventDefault()):i>f.bottom&&(g=b(m))?(e(!1,g),c.preventDefault()):(h<k.left||h>k.right)&&tinymce.each(a.dom.select(".wpview-wrap"),function(a){var b=a.getBoundingClientRect();return i<b.top?!1:i>=b.top&&i<=b.bottom?(h<k.left?(e(!0,a),c.preventDefault()):h>k.right&&(e(!1,a),c.preventDefault()),!1):void 0}))}),a.on("init",function(){var c=!1,d=a.selection,e=window.MutationObserver||window.WebKitMutationObserver;a.on("BeforeSetContent",function(){var c,e,f=b(d.getNode());f&&(!f.nextSibling||b(f.nextSibling)?(e=a.getDoc().createTextNode(""),a.dom.insertAfter(e,f)):(c=new y(f.nextSibling,f.nextSibling),e=c.next()),d.select(e),d.collapse(!0))}),a.dom.bind(a.getDoc(),"touchmove",function(){c=!0}),a.on("mousedown mouseup click touchend",function(a){var d=b(a.target);return A=!1,d?(a.stopImmediatePropagation(),a.preventDefault(),"touchend"===a.type&&c?c=!1:h(d),!1):(("touchend"===a.type||"mousedown"===a.type)&&i(),void("touchend"===a.type&&c&&(c=!1)))},!0),e&&new e(function(){a.fire("wp-body-class-change")}).observe(a.getBody(),{attributes:!0,attributeFilter:["class"]}),tinymce.Env.ie&&a.dom.bind(a.getBody(),"controlselect mscontrolselect",function(a){b(a.target)&&a.preventDefault()})}),a.on("PreProcess",function(a){l(a.node)},!0),a.on("hide",function(){wp.mce.views.unbind(),i(),l()}),a.on("PostProcess",function(a){a.content&&(a.content=a.content.replace(/<div [^>]*?data-wpview-text="([^"]+)"[^>]*>[\s\S]*?<\/div>/g,j).replace(/<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,j))}),a.on("keydown",function(c){var d,j,k,l,o,q,r,s=c.keyCode,t=a.dom,u=a.selection;if(n){if((c.metaKey||c.ctrlKey)&&s!==x.BACKSPACE&&86!==s||s>=112&&123>=s)return void((c.metaKey||c.ctrlKey)&&88===s&&(z=n));if(j=b(u.getNode()),j!==n)return void i();s===x.LEFT?(e(!0,j),c.preventDefault()):s===x.UP?(j.previousSibling?b(j.previousSibling)?e(!0,j.previousSibling):(i(),u.select(j.previousSibling,!0),u.collapse()):e(!0,j),c.preventDefault()):s===x.RIGHT?(e(!1,j),c.preventDefault()):s===x.DOWN?(j.nextSibling?b(j.nextSibling)?e(!1,j.nextSibling):(i(),u.setCursorLocation(j.nextSibling,0)):e(!1,j),c.preventDefault()):m(s)||(g(n),(s===x.ENTER||s===x.DELETE||s===x.BACKSPACE)&&c.preventDefault())}else{if(c.metaKey||c.ctrlKey||s>=112&&123>=s)return;if(d=u.getNode(),p=d,j=b(d),u.isCollapsed()||(o=u.getRng(),(j=b(o.endContainer))?(q=o.cloneRange(),u.select(j.previousSibling,!0),u.collapse(),r=u.getRng(),q.setEnd(r.endContainer,r.endOffset),u.setRng(q)):(j=b(o.startContainer))&&(q=o.cloneRange(),q.setStart(j.nextSibling,0),u.setRng(q))),!j)return void(c.keyCode===x.BACKSPACE&&(a.dom.isEmpty(d)?(j=b(d.previousSibling))&&(e(!1,j),a.dom.remove(d),c.preventDefault()):(o=u.getRng())&&0===o.startOffset&&0===o.endOffset&&(j=b(d.previousSibling))&&(e(!1,j),c.preventDefault())));if(!(k=t.hasClass(j,"wpview-selection-before"))&&!(l=t.hasClass(j,"wpview-selection-after")))return;if(m(s))return;l&&s===x.UP||k&&s===x.BACKSPACE?(j.previousSibling?b(j.previousSibling)?e(!1,j.previousSibling):t.isEmpty(j.previousSibling)&&s===x.BACKSPACE?t.remove(j.previousSibling):(u.select(j.previousSibling,!0),u.collapse()):e(!0,j),c.preventDefault()):!l||s!==x.DOWN&&s!==x.RIGHT?!k||s!==x.UP&&s!==x.LEFT?k&&s===x.DOWN?(j.nextSibling?b(j.nextSibling)?e(!0,j.nextSibling):u.setCursorLocation(j.nextSibling,0):e(!1,j),c.preventDefault()):l&&s===x.LEFT||k&&s===x.RIGHT?(h(j),c.preventDefault()):l&&s===x.BACKSPACE?(g(j),c.preventDefault()):l?f(j):k&&f(j,!0,s):(j.previousSibling&&(b(j.previousSibling)?e(s===x.UP,j.previousSibling):(u.select(j.previousSibling,!0),u.collapse())),c.preventDefault()):(j.nextSibling&&(b(j.nextSibling)?e(s===x.RIGHT,j.nextSibling):u.setCursorLocation(j.nextSibling,0)),c.preventDefault()),s===x.ENTER&&c.preventDefault()}}),a.on("keyup",function(){z&&(g(z),z=!1)}),a.on("focus",function(){var c;r=!0,a.dom.addClass(a.getBody(),"has-focus"),A&&(c=b(a.getBody().firstChild))&&e(!0,c),A=!1}),a.on("blur",function(){r=!1,a.dom.removeClass(a.getBody(),"has-focus")}),a.on("NodeChange",function(d){var f=a.dom,g=a.dom.select(".wpview-wrap"),h=d.element.className,j=b(d.element),k=p;if(p=!1,clearInterval(o),tinymce.each(g,function(a){a.className&&(a.className=a.className.replace(/ ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g,""))}),r&&j)if("wpview-selection-before"!==h&&"wpview-selection-after"!==h||!a.selection.isCollapsed())c(d.element,"wpview-clipboard")||q||(i(),q++,e(!0,j));else{if(q=0,i(),k===j.previousSibling)return void e(!0,j);if(k===j.nextSibling)return void e(!1,j);f.addClass(j,h),o=setInterval(function(){f.hasClass(j,"wpview-cursor-hide")?f.removeClass(j,"wpview-cursor-hide"):f.addClass(j,"wpview-cursor-hide")},500)}}),a.on("BeforeExecCommand",function(){var c,d=a.selection.getNode();d&&((t="wpview-selection-before"===d.className)||"wpview-selection-after"===d.className)&&(c=b(d))&&(f(c,t),s=c)}),a.on("ExecCommand",function(){var b,c;n&&(b=n,i(),h(b)),s&&(c=s[t?"previousSibling":"nextSibling"],c&&"P"===c.nodeName&&a.dom.isEmpty(c)&&(a.dom.remove(c),e(t,s)),s=!1)}),a.on("ResolveName",function(c){a.dom.hasClass(c.target,"wpview-wrap")?(c.name=a.dom.getAttrib(c.target,"data-wpview-type")||"wpview",c.stopPropagation()):b(c.target)&&(c.preventDefault(),c.stopPropagation())}),a.addButton("wp_view_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",onclick:function(){n&&wp.mce.views.edit(a,n)}}),a.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){n&&g(n)}}),a.once("preinit",function(){a.wp&&a.wp._createToolbar&&(u=a.wp._createToolbar(["wp_view_edit","wp_view_remove"]))}),a.on("wptoolbar",function(a){n&&(a.element=n,a.toolbar=u)}),a.wp=a.wp||{},a.wp.getView=b,a.wp.setViewCursor=e,{getView:b}):{getView:B}}); ```
Einar Nilson Gjerstad (Örebro, 30 October 1897 – 8 January 1988) was a Swedish archaeologist. He was most noted for his research of the ancient Mediterranean, particularly known for his work on Cyprus, as well as his studies of early Rome. Biography Gjerstad studied at Uppsala University, where he earned a bachelor's degree. 1920, fil.mag. 1921, fil.lic. 1923, and received his doctorate in 1926. In 1922 he was an assistant at excavations in Asine under Axel W. Persson (1888–1951), professor of classical archaeology and ancient history at Uppsala University. From 1926 until 1935 he was professor of classical archaeology and ancient history at Uppsala University. Gjerstad had the opportunity to go to Cyprus and conduct investigations 1923–1924, for example in Kalopsida. From 1927 until 1931 Gjerstad led the Swedish Cyprus Expedition. The expedition was intended to make a complete study of the ancient culture of Cyprus. Gjerstad served as the expedition's leader with overall responsibility, while Erik Sjöqvist and Alfred Westholm led most of the excavations. He was a pioneer in the study of Cypriot Bichrome ware. From 1935 until 1940, Gjerstad served as director the Swedish Institute at Rome. When Gjerstad left Rome in 1940, he assumed the position of Professor of Classical Archaeology and Ancient History at Lund University. Legacy On 1 November 1972 president of Cyprus, Makarios III, unveiled in the presence of Gjerstad, a stele at the Palace of Vouni in honour of Einar Gjerstad and the work conducted by the Swedish Cyprus Expedition. A street has been named after him in Larnaca, Cyprus. (It is adjacent to the Bamboula archaeological site of Kition.) Publications 1926 Studies on Prehistoric Cyprus 1934 The Swedish Cyprus Expedition: Finds and Results of the Excavation in Cyprus 1927-1931. Vol. I 1935 The Swedish Cyprus Expedition: Finds and Results of the Excavation in Cyprus 1927-1931. Vol. II 1937 The Swedish Cyprus Expedition: Finds and Results of the Excavation in Cyprus 1927-1931. Vol. III 1953 Early Rome Vol. I: Stratigraphical researches in the Forum Romanum and along the Sacra Via 1956 Early Rome Vol. II: The tombs 1960 Early Rome Vol. III: Fortifications, domestic architecture, sanctuaries, stratigraphic excavations 1962 Legends and Facts of Early Roman History 1966 Early Rome Vol. IV: Synthesis of archaeological evidence 1967 Les Origines de la république Romaine: neuf exposés suivis de discussions 1973 Early Rome Vol. V: The written sources 1973 Early Rome Vol. VI: Historical survey 1977 Greek Geometric and Archaic Pottery found in Cyprus, Stockholm: Swedish Institute in Athens. 1980 Ages and Days in Cyprus, Paul Åström, Göteborg. Kıbrıs Macerası – The Cyprus Adventure – Περιπετεια στην Κυπρο  (1927 - 1931), Galeri Kültür Kitabevi, Lefkoşa 2013 Published in three languages: Turkish, English and Greek. Marie-Louise Winbladh, Galeri Kültür Kitabevi, Lefkoşa, Cyprus 2013 Adventuring with Cyprus. A Chronicle of the Swedish Cyprus Expedition 1927 – 1931. Marie-Louise Winbladh 2016 Adventures of an archaeologist. Memoirs of a museum curator, Marie-Louise Winbladh, AKAKIA Publications, London 2020 References Other Sources Einar Gjerstad research papers, 1806-1984, Getty Research Institute, Los Angeles. Accession No. 900228. The archive includes research notes, photographs, drawings, typescripts and publication production materials for Gjerstad's extensive studies of the archaeology of Cyprus and early Rome. "Einar Gjerstad," in A Historical Dictionary of Classical Archaeology, ed. Nancy T. de Grummond (Greenwood Press, Westport, Connecticut 1996). Einar Gjerstad's Cypriote publications. A bibliography by Paul Astrom. Einar Gjerstad research papers, 1806-1984 Finding aid for the Einar Gjerstad research papers, 1806-1984 1897 births 1988 deaths People from Örebro Swedish archaeologists Classical archaeologists 20th-century archaeologists Academic staff of Lund University Uppsala University alumni Corresponding Fellows of the British Academy Members of the Royal Swedish Academy of Sciences
Demirciler is a village in the Bolu District, Bolu Province, Turkey. Its population is 479 (2021). References Villages in Bolu District
```go package css_parser import ( "fmt" "strings" "github.com/evanw/esbuild/internal/ast" "github.com/evanw/esbuild/internal/css_ast" "github.com/evanw/esbuild/internal/css_lexer" "github.com/evanw/esbuild/internal/logger" ) type composesContext struct { parentRefs []ast.Ref parentRange logger.Range problemRange logger.Range } func (p *parser) handleComposesPragma(context composesContext, tokens []css_ast.Token) { type nameWithLoc struct { loc logger.Loc text string } var names []nameWithLoc fromGlobal := false for i, t := range tokens { if t.Kind == css_lexer.TIdent { // Check for a "from" clause at the end if strings.EqualFold(t.Text, "from") && i+2 == len(tokens) { last := tokens[i+1] // A string or a URL is an external file if last.Kind == css_lexer.TString || last.Kind == css_lexer.TURL { var importRecordIndex uint32 if last.Kind == css_lexer.TString { importRecordIndex = uint32(len(p.importRecords)) p.importRecords = append(p.importRecords, ast.ImportRecord{ Kind: ast.ImportComposesFrom, Path: logger.Path{Text: last.Text}, Range: p.source.RangeOfString(last.Loc), }) } else { importRecordIndex = last.PayloadIndex p.importRecords[importRecordIndex].Kind = ast.ImportComposesFrom } for _, parentRef := range context.parentRefs { composes := p.composes[parentRef] for _, name := range names { composes.ImportedNames = append(composes.ImportedNames, css_ast.ImportedComposesName{ ImportRecordIndex: importRecordIndex, Alias: name.text, AliasLoc: name.loc, }) } } return } // An identifier must be "global" if last.Kind == css_lexer.TIdent { if strings.EqualFold(last.Text, "global") { fromGlobal = true break } p.log.AddID(logger.MsgID_CSS_CSSSyntaxError, logger.Warning, &p.tracker, css_lexer.RangeOfIdentifier(p.source, last.Loc), fmt.Sprintf("\"composes\" declaration uses invalid location %q", last.Text)) p.prevError = t.Loc return } } names = append(names, nameWithLoc{t.Loc, t.Text}) continue } // Any unexpected tokens are a syntax error var text string switch t.Kind { case css_lexer.TURL, css_lexer.TBadURL, css_lexer.TString, css_lexer.TUnterminatedString: text = fmt.Sprintf("Unexpected %s", t.Kind.String()) default: text = fmt.Sprintf("Unexpected %q", t.Text) } p.log.AddID(logger.MsgID_CSS_CSSSyntaxError, logger.Warning, &p.tracker, logger.Range{Loc: t.Loc}, text) p.prevError = t.Loc return } // If we get here, all of these names are not references to another file old := p.makeLocalSymbols if fromGlobal { p.makeLocalSymbols = false } for _, parentRef := range context.parentRefs { composes := p.composes[parentRef] for _, name := range names { composes.Names = append(composes.Names, p.symbolForName(name.loc, name.text)) } } p.makeLocalSymbols = old } ```
Franz Xaver Kappus (17 May 1883 – 9 October 1966) was an Austrian military officer, journalist, editor and writer who wrote poetry, short-stories, novels and screenplays. Kappus is known chiefly as the military academy cadet who wrote to Austrian poet Rainer Maria Rilke (1875–1926) for advice in a series of letters from 1902 to 1908 that were assembled and published in the best-selling book Letters to a Young Poet (1929). Life Franz Xaver Kappus was born on 17 May 1883 in Timișoara (also known as German: Temeschwar, Temeschburg or Temeswar, in Hungarian: Temesvár), in the Banat province of the Austro-Hungarian Empire. The Banat region (now divided between Hungary, Serbia and Romania) was populated with a large population of ethnic Germans known as Banat Swabians or Danube Swabians of which Kappus' ancestry is derived. As a 19-year-old officer cadet at the Theresian Military Academy in Wiener Neustadt, Lower Austria, Kappus wrote to Rainer Maria Rilke after learning that as a young man, Rilke, the son of an Austrian army officer, had studied at the academy's lower school at Sankt Pölten in the 1890s. Kappus corresponded with Rilke, then a popular poet at the beginning of his career, in a series of letters from 1902 to 1908, in which he sought Rilke's advice regarding the quality of his poetry, and in deciding between a literary career or a career as an officer in the Austro-Hungarian Army. Aside from his role in writing to Rilke and later publishing these letters, Kappus is largely forgotten by history. Despite the hesitancy he expressed in his letters to Rilke about pursuing a military career, he continued his military studies and served for 15 years as an officer in the Austro-Hungarian Army. During the course of his life, he worked as a newspaper editor and journalist, writing poems, humorous sketches, short-stories, novels, and adapted several works (including his own) into screenplays for films in the 1930s. However, Kappus did not achieve lasting fame. After World War I, he was the editor of several newspapers, including Kappus Deutsche Wacht (trans. "Kappus' German Watch"), later known as Banater Tagblatt (trans. "Banat Daily"), and other newspapers Temeswarer Zeitung (trans. "Timișoara Newspaper"), and the Schwäbische Volkspresse (trans. "Swabian People's Press"). During World War II on 16 June 1945, he was part of a group in Berlin that founded the Liberal Democratic Party of Germany (initially intending to re-use the name "Deutsche Demokratische Partei" of a Weimar-era party), becoming one of its board members. The LDP later became one of the bloc parties under the East German communist regime, after whose fall it merged in 1990 with the West German Freie Demokratische Partei (trans. "Free Democratic Party"), which is affiliated with ideology of classical liberalism. Kappus died on 9 October 1966 in East Berlin at the age of 83. Works Novels 1918: Die lebenden Vierzehn (trans. "Fourteen Survivors") 1921: Die Peitsche im Antlitz (trans. "The whip in the Face") 1922: Der Rote Reiter (trans. "The Red Rider") 1929: Briefe an einen jungen Dichter (trans. "Letters to a Young Poet") 1929: Martina und der Tänzer (trans. "Martina and the Dancers") 1935: Brautfahrt um Lena (trans. "Lena, spoken for") 1941: Flammende Schatten (trans. "Blazing Shadows") 1949: Flucht in die Liebe (trans. "Escape into Love") Screenwriter 1923: Der Rote Reiter (trans. The Red Rider), from his novel 1926: The Woman in Gold 1926: Les voleurs de gloire 1935: Der Rote Reiter (trans. The Red Rider), from his novel, directed by Rolf Randolf 1944: The man to whom they stole the name See also German literature Lists of authors List of German-language authors List of German-language poets References Notes Further reading Adel, Kurt. Franz Xaver Kappus (1883–1966): Österreicher Offizier under deutscher Schriftsteller (Peter Lang GmbH, 2006). * Totok, William. From Expressionism to Entertainment, NewsPad, November 14, 2006. William Totok: Franz Xaver Kappus între isterie de război şi pacifism moderat (deutsch Franz Xaver Kappus zwischen Kriegshysterie und moderatem Pazifismus). In: Franz Xaver Kappus, Biciul disprețului. Povestea unui stigmatizat / Die Peitsche im Antlitz. Geschichte eines Gezeichneten. Prefaţă, tabel cronologic şi ediţie bilingvă îngrijită de William Totok. Traducere din limba germană de Werner Kremm, Editura Muzeul Literaturii Române, București 2018. 1883 births 1966 deaths Austro-Hungarian Army officers Austro-Hungarian culture Danube-Swabian people German male journalists Writers from Timișoara German male poets 20th-century German poets German-language poets 20th-century German male writers Emigrants from Austria-Hungary to Germany 20th-century German journalists
The Akali movement , also called the Gurdwara Reform Movement, was a campaign to bring reform in the gurdwaras (the Sikh places of worship) in India during the early 1920s. The movement led to the introduction of the Sikh Gurdwara Bill in 1925, which placed all the historical Sikh shrines in India under the control of Shiromani Gurdwara Parbandhak Committee (SGPC). The Akalis also participated in the Indian independence movement against the British Government, and supported the non-cooperation movement against them. Formation Sikh leaders of the Singh Sabha in a general meeting in Lahore in March 1919 formed the Central Sikh League in March 1919, which was formally inaugurated in December of that year. In its periodical, the Akali, it listed among its objectives the goals of bringing back control of the Khalsa College, Amritsar under the control of representatives of the Sikh community (accomplished in November 1920 by negating government control through refusing government grants), liberating gurdwaras from mahant control, and encouraging Sikhs to participate in the independence movement, lending support to the non-cooperation movement in October 1919. The Central Sikh League demanded the administration of the Golden Temple to be transferred from the government to an elected representative body of Sikhs answerable to the panth, and in October 1920 took control of the Golden Temple and Akal Takht. The Jallianwala Bagh massacre in April 1919 during the course of the national independence movement, subsequent words of support from Arur Singh, the head priest of the Golden Temple, to General Dyer, and the general disturbances in Punjab in 1919 provoked an outcry among Singh Sabha circles, and increased Sikh urgency to reclaim control of the gurdwaras. To pacify these sentiments, the colonial Punjab Government appointed a provisional committee of 36 members, entirely from Sikh landed aristocrat families, to formulate proposals regarding the operation of the Golden Temple. Following the Central Sikh League's disapproval of the committee's composition, expressed in a large gathering at the Golden Temple on 16 November 1920 attended by over 10,000 Sikhs, the committee in charge of the Golden Temple was reformulated with 175 members to form a managing committee for all gurdwaras. The government, publicly pursuing a policy of neutral non-interference though still managing to have some appointees on the committee, allowed the new committee, and in December 1920 the committee was named the Shiromani Gurdwara Prabandhak Committee, or SGPC, which coordinated the activities of Akali jathas, or volunteer groups, to liberate all gurdwaras from the corrupt mahants. The Akali movement was started in 1920 by the Central Sikh League's political wing, the Akali Dal, which was founded in Amritsar in December 1920 and assisted the SGPC. The term Akali derives from the word Akal ("timeless" or "immortal") used in the Sikh scriptures. The movement was named for the Akalis, a Khalsa militant order from the time of Guru Gobind Singh which had risen to prominence under Akali Phula Singh, one of the commanders of the Sikh Empire. Initial agitations By the early 20th century, a number of Sikh gurdwaras in British India were under the control of the Udasi mahants (clergymen) or managers appointed by the Governors. The Udasis had come to control Sikh shrines in the eighteenth century during the period of increased persecution of the Khalsa by the Mughal Empire during that time forced them to yield control of Sikh institutions to those without external identifiers; the Khalsa would subsequently focus on political power resulting in the Sikh Empire. The main aim of the Akali movement was to have the Sikh gurdwaras released from the control of the traditional clergy, which had become powerful and ritualized. The non-violent movement began in 1920, with the jathas, led by Kartar Singh Jhabbar, playing a major role. The first shrine chosen for reform was the Babe di Ber gurdwara in Sialkot. It was under the control of the widow of the mahant Harnam Singh. She initially resisted the takeover of the gurdwara by the Akalis, as it was her only source of income, but relented after she was offered a pension. The control of the gurdwara was then transferred to an elected committee headed by Baba Kharak Singh. The next major target of the Akalis was the Harmandir Sahib (Golden Temple), the holiest shrine of the Sikhs. The priest of the Golden Temple had refused to allow low-caste Hindu converts to offer prayers in the shrine. Kartar Singh Jhabbar walked to the Akal Takht in the temple premises, urging the Sikhs to give up the caste-based restrictions and reform the gurdwaras. On 28 June 1920, the Golden Temple came under the control of an elected committee called Shiromani Gurdwara Parbandhak Committee (SGPC). Next, the Akalis headed to Hasan Abdal, where Gurdwara Panja Sahib was under the control of Mahant Mitha Singh. Singh allowed sale of cigarettes inside the gurdwara, and was disliked by the Sikhs. The Akalis led by Kartar Singh Jhabbar took control of the gurdwara on 20 November 1920. However, the local Hindus, who also frequented the gurdwara for worship, opposed this takeover. Around 5–6 thousand of them surrounded the gurdwara on the night of the Akali takeover, but were dispersed by the police. Nevertheless, the gurdwara was later successfully brought under the authority of the SGPC. The Akalis then took control of the Gurdwara Sacha Sauda at Chuhar Kana (in present-day Pakistan). They then turned their attention to the Gurdwara Sri Tarn Taran Sahib, whose clergymen were accused of allowing dancing girls, smoking and drinking inside the shrine's premises. The clergymen were also accused of spreading the teachings of Arya Samaj, a Hindu reform movement some of whose leaders had criticized Sikhism. A group of 40 Akalis, led by Kartar Singh, arrived at the gurdwara on 25 January 1921, performed ardas (Sikh prayer) and declared that the gurdwara was now under their control. Henchmen employed by the mahants attacked the Akalis with crude bombs and bricks while the latter were sleeping. Two Akalis were killed and several wounded, and a jatha two weeks prior had also been beaten. The next day, the Sikhs from the surrounding villages took control of the Gurdwara, and a managing committee appointed by the SGPC. Following this, the Akalis led by Kartar Singh then took control of five more gurdwaras, including the Gurdwara Guru ka Bagh near Amritsar. The British, believing that gurdwara control could be contested in court, did not like the control of gurdwaras passing under the control of committees appointed by the SGPC. Nankana massacre In 1921, the Akalis turned their focus to the gurdwara at Nankana Sahib, the birthplace of the first Sikh Guru Nanak. The gurdwara was under the control of a mahant called Narain Das, who was accused of allowing immoral activities in the temple premises, including licentiousness and the misappropriation of gurdwara funds. One of the clergymen at the gurdwara had allegedly raped the 13-year-old daughter of a Hindu devotee from Sindh. The mahant's conduct had been widely condemned by the local congregation, though the large revenue from the gurdwara estates insulated him from public pressure. With the movement gaining momentum, public meetings passed resolutions condemning his conduct, and worried about being ousted by the Akalis, he turned to the government for help. When the government did not respond, Narain Das made his own arrangements, preemptively fortifying the premises and hiring approximately 80 mercenaries. When a jatha of over 100 Sikh made an unscheduled trip to Nankana on 20 February 1921 without any intention yet of taking it, the Pashtun guards of the Mahant opened fire without warning, killing 130 people in what came to be known as the Nankana massacre. Visitors attempting to seek refuge in the gurdwara were chased and killed, and piles of dead and wounded were lit on fire to attempt to destroy evidence of the massacre. Reaction Two days later, Mahatma Gandhi and the Governor of the Punjab province visited the site, accompanied by a number of Sikh and Hindu leaders. Gandhi sympathized with the Sikhs and said that the Mahant had "out-Dyered Dyer." The attending politicians utilized widespread anti-government feelings to exhort the Sikhs to join the national noncooperation movement, which was supported by a resolution passed by the SGPC in May 1921 appealing to Sikhs to begin civil disobedience. As the Sikh reformers were now aligned with the national movement, colonial administrators began to rethink its position on non-interference in gurdwara management and acceptance of the increasing control of the SGPC. Akalis headed to Nankana upon hearing the news in the thousands, and access to the gurdwara was restricted by the government, though eventually conceded. The British Government, finding itself under immense political pressure, agreed to transfer the control of the gurdwara to the Akalis on 3 March 1921. Narain Das and 26 of his henchmen were arrested. A section of Akalis rejected the peaceful methods adopted by SGPC, and formed the breakaway Babbar Akali movement to seize the control of the gurdwaras using violent methods. Some Akalis and Ghadarites would react against the killing of the Nankana massacre, attempting assassinations against officials held responsible for the killings, as well as their native supporters. Arrests of the militant leaders would follow, but the Babbar Akali Jatha, founded in August 1922 with the aim of defending the faith and political independence, would make overtures to ex-soldiers and the Akali reformers, as well as to Hindus and Muslims who opposed the authorities. They issued 15 issues of the Babbar Akali Doaba from a moving press throughout Jalandhar and Hoshiarpur from August 1922 to May 1923, and in 1923 committed a series of political assassinations; they were declared unlawful in August 1923 and in under a year most Babbar Akali leaders would be arrested or killed. Those arrested would be tried in 1925 and considered to be fighting for independence and Sikh rule, with six hangings in February 1926. Several organizations, including the Central Sikh League, would issued appeals to raise funds for the families of those killed and hanged, and they would be celebrated in poetry and literature. Resistance movements Amid the ongoing agitations, the SGPC urged the British Government to release the protestors and legalize its control of the gurdwaras. On 1 May 1921, the influential Sikh leaders passed a resolution for launching a passive resistance movement. The next day, a Sikh-Hindu conference was organized during the Punjab Congress Provincial Congress at Rawalpindi. The Jagat Guru Shankaracharya urged the Hindus to join the Sikhs in the struggle for taking control of the gurdwaras from mahants with personal interests. On 11 May, a number of Akali jathas were asked to proceed to designated gurdwaras to take over their control. Morcha Chabian ("Keys Campaign") In October 1921, the SGPC executive committee passed a resolution asking Sunder Singh Ramgharia, a mahant previously appointed by the government who subsequently assumed a position as an SGPC secretary, to relinquish the keys of the Golden Temple's toshakhana, or vault, to the committee, as he represented government control over the temple's treasures and artifacts. The government would take possession of the keys in November, when Sunder Singh would seek the advice of the Deputy Commissioner, who sent his subordinate Lala Amar Nath to take the keys. which prompted the SGPC to accuse the government of meddling in Sikh affairs, and appeal to Akali jathas to meet at Amritsar and organize protest meetings. The government would in response affix their own locks to the toshakhana in defiance, escalating the situation, and Akali protestors were arrested and given punishments. The conflict between the Sikhs and the government also lead to the consolidation of ties between the Akalis and noncooperation leaders, and the allegations of government interference in religious affairs began to affect the public opinion of Sikh soldiers, disbanded soldiers, and peasantry, on which colonial stability depended, and the threat of a major civil disobedience at the beginning of 1922. To prevent unrest, the government relented, handing over the toshakhana keys to the Baba Kharak Singh of the SGPC on 17 January 1922, and agreed to the unconditional release of all Sikhs arrested, the number of whom had been increasing up to that point. As Sikh concerns were now linked with the wider non-cooperation movement, Gandhi would telegraph the SGPC in January 1922 with "Congratulations, first decisive battle for India's freedom won." The government's attitude toward the Akalis would grow more contentious by midyear however, as the Akalis would begin to consider independence as their best option. Guru-ka-Bagh The most notable conflict between the Akalis and the colonial government, highlighting the larger problem of private resource management of gurdwaras, occurred in August 1922 at the Guru-ka-Bagh ("garden of the guru") shrine 12 miles from Amritsar near Ajnala, built to mark a visit from Guru Arjan. The struggle between the Akalis and the mahant Sunder Das over the control of the site had resulted in the mahant keeping his position, though as part of a managing committee that would supervise him, similar to the toshakhana arrangement. However, in March 1921, the mahant reneged on the agreement, forcibly occupying the committee's office and destroying its records. A year later in August 1922, Akali volunteers chopped wood on land to fuel the fires of the gurdwara's free community kitchen, for which the mahant had them arrested for theft at the encouragement of the authorities, provoking a major struggle with the Akalis, who contended that the mahant could not claim private possession of the property, as it belonged to the Sikh panth, or congregation. The Akalis warned the government that denying Sikhs the right to gather fuel for the community kitchen was to deliberately undermine their faith, and the arrests drew more Akali volunteers to the site, with the SGPC launching a campaign to send non-violent Akali jathas to the gurdwara daily. Over 200 volunteers were arrested by August 25, and by October 19 over 2,450 would be arrested by authorities. As continuous waves of Akalis kept arriving, the authorities began to use violent methods, being declared an unlawful assembly, as bands of 50 to 100, and sometimes over 200 Akalis would take blows in non-violent resistance. On October 25, a jatha of retired soldiers reached the site, which was deemed by the government to be potentially destabilizing. National Non-cooperation leaders rallied to the cause by making speeches at the site, though support from Congress would wane after Gandhi's release in February 1924 as he wanted to separate the political issue of independence from religion. Christian missionary C.F. Andrews, visiting the site in September 1922, was shocked at the administration's brutality, describing Akali tactics as "a new lesson in moral warfare." He protested to Edward MacLagan, the Lieutenant-Governor of Punjab, and the conflict was settled by having the mahant sell the land to Sir Ganga Ram, a private Hindu philanthropist, who handed it over to the Akalis on 17 November 1922. Over 5,000 volunteers were released in March 1923. Gurdwara Bill The Government meanwhile launched a "Gurdwara Bill" to facilitate the settlement of the gurdwara disputes. The Bill provided setting up a Board of Commissioners for the management of the gurdwaras. However, the SGPC objected to the Government's right to appoint the Board members, and the bill was postponed. In On 17 November 1922, the "Sikh Gurdwaras and Shrines Bill" was introduced in the Punjab Legislative Assembly. All the Sikh and the Hindu members opposed the bill, but it was passed by 41 votes to 31 votes. Jaitu and Bhai Pheru agitations In 1923, the Akalis made plans to bring under their control Gurdwara Gangsar at Jaitu (or Jaito) in the Nabha State. The erstwhile Maharaja (ruler) of Nabha Ripudaman Singh had been sympathetic to the Akali and the Indian nationalist cause, but was deposed by the British Government, made to abdicate to his minor son on 9 July 1923. The SGPC held protest meetings, and on 4 August resolved to take up the cause, condemning the act in a meeting at Jaito on 25 August. When the SGPC launched an agitation, its leaders and members were arrested on the charge of sedition. Subsequently, several marches were organized in support of the agitation. The protesters were arrested, beaten and shot at by the police at various instances. With the disruption of a subsequent Akhand Path ceremony, the SGPC condemned the act and resolved to fight for the Sikh right of free worship, sending jathas from the Akal Takht to Jaito to complete the ceremony. The SGPC and Akali Dal were declared to be unlawful organizations on 12 October 1923, with the 60 members of the Jaito morcha committee arrested for treason against the Crown, though the members were replaced and the morcha continued. A jatha of 500 Akalis, seen off from Amritsar by a crowd of 30,000, was sent to mark the third anniversary of the Nankana massacre, and was fired upon by on the command of British administrators in Nabha, with about 300 injured, resulting in about 100 deaths. Jathas continued to Jaito until 101 akhand paths were completed on 6 August 1925, establishing the right to free worship. The Indian National Congress declared its support for the Akali agitation in at the special Congress Session in Delhi. The Akalis were then joined by several non-Sikhs, including Jawaharlal Nehru (later the first Prime Minister of India) and Kasturiranga Santhanam. Nehru and others were arrested during one such march. Finally, the Government of Punjab relented and agreed to transfer the control of the gurdwara to the Akalis. While the Jaitu agitation was on, the Akalis also sought the control of the gurdwara at Bhai Pheru. The gurdwara was controlled by Udasi mahants including Pala Ram, the brother of Narain Das (who was responsible for the Nankana massacre). The mahant agreed to transfer the control of the gurdwara to SGPC, after being offered a pension. However, in August 1923, when the Akalis decided to eject the Udasi tenants housed in the gurdwara premises, they faced considerable resistance. On 4 December 1923, a group of Akalis damaged a mahant's residence attached to the shrine. The police arrested 11 Akalis following a complaint. In December, the Government recognized the SGPC as the manager of the gurdwara, but also ordered the Akalis to follow the legal process for ejecting the Udasi mahants out of the premises. On 1 January 1924, an Akali jatha forcibly took the possession of the property occupied by Pala Ram. Around 34 Akalis were arrested by the police for this action on the next day. In subsequent days, a number of Akali jathas staged demonstrations at the site. A total of 5,251 persons were arrested for the demonstrations, and 3,092 of these were sent to the prison. Sikh Gurdwara Bill The British Government considered the Akali movement to be a greater threat than Mahatma Gandhi's civil disobedience movement. A 1921 memorandum signed by D. Petrie, the Assistant Director of CID, Punjab states: In 1925, after further demands and protests from SGPC, a new "Sikh Gurdwara Bill" was introduced in the Punjab Legislative Assembly on 7 May and adopted in July. It came into force on 1 November 1925, and awarded the control of all the historical shrines to SGPC. A tribunal was set up to judge the disputes, and all the Akali prisoners were released. By this time, an estimated 30,000 people had been arrested by the British Government; over 400 had been killed and another 2,000 had been injured during the movement. The movement fueled the anti-British Government feeling among the Sikhs. It also led to an anti-Hindu sentiment among a section of Sikhs, who identified the pro-Udasi mahants such as Narain Das and their supporters with the Hindu community. As the British authorities came to see the Akali movement to be a movement to overthrow the British and therefore to be suppressed, in addition to the casualties and arrests, there had been confiscation of properties and jagirs, fines, court-martials for wearing the kirpan, or Sikh dagger, and black turbans traditionally signalling revolt, and penalties against publishers, editors, and presses supportive of the movement. The movement found support from almost all sections of the Sikh community, especially the peasantry, artisans, laborers, ex-soldiers, and emigrants returning from abroad. References Further reading 1920 establishments in British India 1925 disestablishments in British India 1920s in India 1920s protests History of Sikhism Nonviolent resistance movements Protests in British India 1920 in India
Paul Raymond Hutchins (5 April 1945 – 14 March 2019) was a British tennis player and Davis Cup player. He was the longest serving British Davis Cup captain, being in charge for 31 matches and 13 years, including the 1978 final. Biography Born in Bristol, Hutchins was educated at Millfield School. Hutchins was a Davis Cup player and Captain for Great Britain from 1975 to 1987. In 1968, he made the third round of the men's singles at the French Open and the US Open, and the quarterfinals of the men's doubles at the French, partnering Gerald Battrick. Hutchins largely stopped playing at the age of 25 due to injury, though he did play a few matches in 1972 & 1973. He had four children, the most noteworthy being Ross, a former ATP Pro. References External links 1945 births 2019 deaths Members of the Order of the British Empire English male tennis players British male tennis players Tennis people from Bristol Neurological disease deaths in the United Kingdom Deaths from motor neuron disease People educated at Millfield
Saint-Cernin (; ) is a commune in the Cantal department in south-central France. Population See also Communes of the Cantal department References Communes of Cantal Cantal communes articles needing translation from French Wikipedia
```xml // Libraries import React, {PureComponent} from 'react' // Decorators import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { link: string } class TooltipLink extends PureComponent<Props> { public render() { const {link} = this.props return ( <p> Still have questions? Check out the{' '} <a target="_blank" href={link}> Flux Docs </a> . </p> ) } } export default ErrorHandling(TooltipLink) ```
```smalltalk Class { #name : 'OCCodeReparatorTest', #superclass : 'TestCase', #category : 'OpalCompiler-Tests-FromOld', #package : 'OpalCompiler-Tests', #tag : 'FromOld' } { #category : 'tests' } OCCodeReparatorTest >> testDeclareClassVar [ | requestor method goo | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. goo := MockForCompilation classVariableNamed: #goo ifAbsent: [ nil ]. goo ifNotNil: [ MockForCompilation removeClassVariable: goo ]. method := [ OpalCompiler new class: MockForCompilation ; compile: requestor text ] on: OCUndeclaredVariableWarning , CodeError do: [ :e | e notice reparator declareClassVar. e retry ]. self assert: requestor text withSeparatorsCompacted equals: 'griffle ^ goo'. self assert: method isCompiledMethod. goo := MockForCompilation classVariableNamed: #goo. self assert: method literals first equals: goo. MockForCompilation removeClassVariable: goo ] { #category : 'tests' } OCCodeReparatorTest >> testDeclareClassVarBlock [ | compiler requestor method goo | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. goo := MockForCompilation classVariableNamed: #goo ifAbsent: [ nil ]. goo ifNotNil: [ MockForCompilation removeClassVariable: goo ]. method := (compiler := OpalCompiler new) class: MockForCompilation; failBlock: [ :notice | notice reparator declareClassVar. compiler compile ]; compile: requestor text. self assert: requestor text withSeparatorsCompacted equals: 'griffle ^ goo'. self assert: method isCompiledMethod. goo := MockForCompilation classVariableNamed: #goo. self assert: method literals first equals: goo. MockForCompilation removeClassVariable: goo ] { #category : 'tests' } OCCodeReparatorTest >> testDeclareGlobal [ | requestor method | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. Smalltalk globals removeKey: #goo ifAbsent: []. method := [ OpalCompiler new compile: requestor text ] on: OCUndeclaredVariableWarning , CodeError do: [ :e | e notice reparator declareGlobal. e retry ]. self assert: requestor text withSeparatorsCompacted equals: 'griffle ^ goo'. self assert: method isCompiledMethod. self assert: method literals first equals: (Smalltalk globals associationAt: #goo). self assert: method sourceCode withSeparatorsCompacted equals: 'griffle ^ goo'. Smalltalk globals removeKey: #goo ifAbsent: [] ] { #category : 'tests' } OCCodeReparatorTest >> testDeclareGlobalBlock [ | compiler requestor method | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. Smalltalk globals removeKey: #goo ifAbsent: []. method := (compiler := OpalCompiler new) class: MockForCompilation; failBlock: [ :notice | notice reparator declareGlobal. compiler compile ]; compile: requestor text. self assert: requestor text withSeparatorsCompacted equals: 'griffle ^ goo'. self assert: method isCompiledMethod. self assert: method literals first equals: (Smalltalk globals associationAt: #goo). self assert: method sourceCode withSeparatorsCompacted equals: 'griffle ^ goo'. Smalltalk globals removeKey: #goo ifAbsent: [] ] { #category : 'tests' } OCCodeReparatorTest >> testDeclareInstVar [ | requestor method | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. (MockForCompilation hasInstVarNamed: #goo) ifTrue: [ MockForCompilation removeInstVarNamed: #goo ]. self deny: (MockForCompilation hasInstVarNamed: #goo). method := [ OpalCompiler new class: MockForCompilation ; compile: requestor text ] on: OCUndeclaredVariableWarning , CodeError do: [ :e | e notice reparator declareInstVar: #goo. e retry ]. self assert: requestor text withSeparatorsCompacted equals: 'griffle ^ goo'. self assert: method isCompiledMethod. self assert: (MockForCompilation hasInstVarNamed: #goo). MockForCompilation removeInstVarNamed: #goo ] { #category : 'tests' } OCCodeReparatorTest >> testDeclareInstVarBlock [ | compiler requestor method | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. (MockForCompilation hasInstVarNamed: #goo) ifTrue: [ MockForCompilation removeInstVarNamed: #goo ]. self deny: (MockForCompilation hasInstVarNamed: #goo). method := (compiler := OpalCompiler new) class: MockForCompilation; failBlock: [ :notice | notice reparator declareInstVar: #goo. compiler compile ]; compile: requestor text. self assert: requestor text withSeparatorsCompacted equals: 'griffle ^ goo'. self assert: method isCompiledMethod. self assert: (MockForCompilation hasInstVarNamed: #goo). MockForCompilation removeInstVarNamed: #goo ] { #category : 'tests' } OCCodeReparatorTest >> testDeclareTempAndPaste [ | requestor method | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. method := [ OpalCompiler new compile: requestor text ] on: OCUndeclaredVariableWarning , CodeError do: [ :e | e notice reparator requestor: requestor; declareTempAndPaste: 'goo'. e retry ]. self assert: requestor text withSeparatorsCompacted equals: 'griffle | goo | ^ goo'. self assert: method isCompiledMethod. self assert: method sourceCode withSeparatorsCompacted equals: 'griffle | goo | ^ goo' ] { #category : 'tests' } OCCodeReparatorTest >> testDeclareTempAndPasteBlock [ | compiler requestor method | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. method := (compiler := OpalCompiler new) class: MockForCompilation; failBlock: [ :notice | notice reparator requestor: requestor; declareTempAndPaste: 'goo'. compiler compile: requestor text ]; compile: requestor text. self assert: requestor text withSeparatorsCompacted equals: 'griffle | goo | ^ goo'. self assert: method isCompiledMethod. self assert: method sourceCode withSeparatorsCompacted equals: 'griffle | goo | ^ goo' ] { #category : 'tests' } OCCodeReparatorTest >> testPossibleVariablesFor [ | requestor names | requestor := OCMockRequestor new. requestor text: 'griffle | foo | ^ goo'. names := [ OpalCompiler new compile: requestor text ] on: OCUndeclaredVariableWarning , CodeError do: [ :e | e notice reparator requestor: requestor; possibleVariablesFor: #goo. ]. self assert: (names includes: #foo) ] { #category : 'tests' } OCCodeReparatorTest >> testPossibleVariablesForBlock [ | compiler requestor names | requestor := OCMockRequestor new. requestor text: 'griffle | foo | ^ goo'. names := (compiler := OpalCompiler new) class: MockForCompilation; failBlock: [ :notice | notice reparator possibleVariablesFor: #goo ]; compile: requestor text. self assert: (names includes: #foo) ] { #category : 'tests' } OCCodeReparatorTest >> testSubstituteVariableAtInterval [ | requestor method | requestor := OCMockRequestor new. requestor text: 'griffle | foo | ^ goo'. method := [ OpalCompiler new compile: requestor text ] on: OCUndeclaredVariableWarning , CodeError do: [ :e | e notice reparator requestor: requestor; substituteVariable: 'foo' atInterval: e node sourceInterval. e retry ]. self assert: requestor text withSeparatorsCompacted equals: 'griffle | foo | ^ foo'. self assert: method isCompiledMethod. self assert: method sourceCode withSeparatorsCompacted equals: 'griffle | foo | ^ foo' ] { #category : 'tests' } OCCodeReparatorTest >> testSubstituteVariableAtIntervalBlock [ | compiler requestor method | requestor := OCMockRequestor new. requestor text: 'griffle | foo | ^ goo'. method := (compiler := OpalCompiler new) class: MockForCompilation; failBlock: [ :notice | notice reparator requestor: requestor; substituteVariable: 'foo' atInterval: notice node sourceInterval. compiler compile: requestor text ]; compile: requestor text. self assert: requestor text withSeparatorsCompacted equals: 'griffle | foo | ^ foo'. self assert: method isCompiledMethod. self assert: method sourceCode withSeparatorsCompacted equals: 'griffle | foo | ^ foo' ] { #category : 'tests' } OCCodeReparatorTest >> testUndeclaredVariable [ | requestor method flag | requestor := OCMockRequestor new. requestor text: 'griffle ^ goo'. flag := false. method := [ OpalCompiler new compile: requestor text ] on: OCUndeclaredVariableWarning , CodeError do: [ :e | flag := true. e resume "continue" ]. self assert: flag. self assert: method isCompiledMethod. self assert: method literals first isUndeclaredVariable. self assert: method sourceCode withSeparatorsCompacted equals: 'griffle ^ goo' ] { #category : 'tests' } OCCodeReparatorTest >> testdefineClass [ self skip. "we need to resume: not with true, but the code, ProvideAnswerNotification needs to be improved to provide the defaultAnswer, too" [ OCCodeReparator new node: (self class>>#testdefineClass) ast; defineClass: 'MyTestClassForDefineClass' ] on: ProvideAnswerNotification do: [ :e | e resume: true ]. self assert: (Smalltalk globals hasClassNamed: #MyTestClassForDefineClass). Smalltalk globals removeClassNamed: #MyTestClassForDefineClass ] { #category : 'tests' } OCCodeReparatorTest >> testdefineTrait [ self skip. "we need to resume: not with true, but the code, ProvideAnswerNotification needs to be improved to provide the defaultAnswer, too" [ OCCodeReparator new node: (self class>>#testdefineTrait) ast; defineTrait: 'MyTestTraitForDefineTrait' ] on: ProvideAnswerNotification do: [ :e | e resume: true ]. self assert: (Smalltalk traitNames includes: #MyTestTraitForDefineTrait). Smalltalk globals removeClassNamed: #MyTestTraitForDefineTrait ] ```
```c++ /* */ /* * This file is part of Scylla. * * Scylla is free software: you can redistribute it and/or modify * (at your option) any later version. * * Scylla is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with Scylla. If not, see <path_to_url */ #include "view_update_from_staging_generator.hh" namespace db::view { future<> view_update_from_staging_generator::start() { _started = seastar::async([this]() mutable { while (!_as.abort_requested()) { if (_sstables_with_tables.empty()) { _pending_sstables.wait().get(); } while (!_sstables_with_tables.empty()) { auto& entry = _sstables_with_tables.front(); schema_ptr s = entry.t->schema(); flat_mutation_reader staging_sstable_reader = entry.sst->read_rows_flat(s); auto result = staging_sstable_reader.consume_in_thread(view_updating_consumer(s, _proxy, entry.sst, _as), db::no_timeout); if (result == stop_iteration::yes) { break; } entry.t->move_sstable_from_staging_in_thread(entry.sst); _registration_sem.signal(); _sstables_with_tables.pop_front(); } } }); return make_ready_future<>(); } future<> view_update_from_staging_generator::stop() { _as.request_abort(); _pending_sstables.signal(); return std::move(_started).then([this] { _registration_sem.broken(); }); } future<> view_update_from_staging_generator::register_staging_sstable(sstables::shared_sstable sst, lw_shared_ptr<table> table) { if (_as.abort_requested()) { return make_ready_future<>(); } _sstables_with_tables.emplace_back(std::move(sst), std::move(table)); _pending_sstables.signal(); return _registration_sem.wait(1); } } ```
The New Zealand Institute of Economic Research (NZIER) is the largest independent think tank in New Zealand. It is non-profit incorporated society and was established in 1958. It seeks to take a centrist, politically neutral position. It has a staff of more than 30 people and is probably the largest economic research unit in New Zealand outside of government. Most of its work is commercial microeconomic consultancy for businesses. It also does public good work. Past directors include Alan Bollard and Brian Easton, and a past chair was Ron Trotter. The Institute owns a MONIAC computer that is currently on loan to the Reserve Bank of New Zealand museum. References External links New Zealand Institute of Economic Research The evolving Institute: 50 years of the NZ Institute of Economic Research, 1958-2008 Think tanks based in New Zealand Economy of New Zealand Economic research institutes Royal Society of New Zealand
```objective-c /* * */ #pragma once #include_next "mbedtls/gcm.h" #include "sdkconfig.h" #ifdef __cplusplus extern "C" { #endif #if defined(MBEDTLS_GCM_ALT) && defined(MBEDTLS_GCM_NON_AES_CIPHER_SOFT_FALLBACK) /** * When the MBEDTLS_GCM_NON_AES_CIPHER_SOFT_FALLBACK is defined, for non-AES GCM * operations we need to fallback to the software function definitions of the * mbedtls GCM layer. * Thus in this case we need declarations for the software funtions. * Please refer mbedtls/include/mbedtls/gcm.h for function documentations */ void mbedtls_gcm_init_soft(mbedtls_gcm_context_soft *ctx); int mbedtls_gcm_setkey_soft(mbedtls_gcm_context_soft *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits); int mbedtls_gcm_starts_soft(mbedtls_gcm_context_soft *ctx, int mode, const unsigned char *iv, size_t iv_len); int mbedtls_gcm_update_ad_soft(mbedtls_gcm_context_soft *ctx, const unsigned char *add, size_t add_len); int mbedtls_gcm_update_soft(mbedtls_gcm_context_soft *ctx, const unsigned char *input, size_t input_length, unsigned char *output, size_t output_size, size_t *output_length); int mbedtls_gcm_finish_soft(mbedtls_gcm_context_soft *ctx, unsigned char *output, size_t output_size, size_t *output_length, unsigned char *tag, size_t tag_len); int mbedtls_gcm_crypt_and_tag_soft(mbedtls_gcm_context_soft *ctx, int mode, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, size_t tag_len, unsigned char *tag); int mbedtls_gcm_auth_decrypt_soft(mbedtls_gcm_context_soft *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *tag, size_t tag_len, const unsigned char *input, unsigned char *output); void mbedtls_gcm_free_soft(mbedtls_gcm_context_soft *ctx); #endif /* MBEDTLS_GCM_ALT && MBEDTLS_GCM_NON_AES_CIPHER_SOFT_FALLBACK*/ #ifdef __cplusplus } #endif ```
Tyrone is a town in northeastern Texas County, Oklahoma, United States. The population was 729 at the 2020 census. History The town was reportedly named by a railway vice president when the railroad passed through the area. It was named after Tyrone, Pennsylvania, where the V.P.'s mother lived. The towns on the railway in Texas County (see below) were 10 miles apart, either for the distance between railroad worker camps, or because of needs for water by locomotives at that distance apart. Nearby Shades Well (three miles northeast) was the trailhead for many cattle drives in the late 19th century. It was larger than Dodge City for a time, and still has mounds of broken glass from beer and whisky bottles consumed by drovers. The trailhead later moved again and it was abandoned. Geography Tyrone is located at . According to the United States Census Bureau, the town has a total area of , all land. Demographics As of the census of 2000, there were 880 people, 324 households, and 243 families residing in the town. The population density was . There were 374 housing units at an average density of . The racial makeup of the town was 77.39% White, 0.34% African American, 0.57% Native American, 0.11% Asian, 18.64% from other races, and 2.95% from two or more races. Hispanic or Latino of any race were 23.52% of the population. There were 324 households, out of which 40.7% had children under the age of 18 living with them, 60.8% were married couples living together, 10.5% had a female householder with no husband present, and 25.0% were non-families. 21.6% of all households were made up of individuals, and 5.6% had someone living alone who was 65 years of age or older. The average household size was 2.72 and the average family size was 3.18. In the town, the population was spread out, with 31.1% under the age of 18, 9.8% from 18 to 24, 30.5% from 25 to 44, 21.4% from 45 to 64, and 7.3% who were 65 years of age or older. The median age was 31 years. For every 100 females, there were 97.8 males. For every 100 females age 18 and over, there were 98.7 males. The median income for a household in the town was $33,550, and the median income for a family was $37,500. Males had a median income of $28,438 versus $20,156 for females. The per capita income for the town was $12,826. About 6.0% of families and 8.9% of the population were below the poverty line, including 9.1% of those under age 18 and 12.1% of those age 65 or over. Transportation Tyrone is on U.S. Route 54, northeast of Hooker and southwest of Liberal, Kansas. Commercial air transportation is available at Liberal Mid-America Regional Airport in Kansas, approximately 11 miles northeast. References Towns in Texas County, Oklahoma Towns in Oklahoma Oklahoma Panhandle
The 1967 Mr. Olympia contest was an IFBB professional bodybuilding competition held in September 1967 at the Brooklyn Academy of Music in Brooklyn, New York. It was the 3rd Mr. Olympia competition held. Results Notable events Sergio Oliva wins the title, becoming the second Mr. Olympia References External links Mr. Olympia 1967 1967 in American sports 1967 in bodybuilding
```yaml # This file has been generated by hack/update-gatekeeper-crds.sh, DO NOT EDIT. apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.11.3 labels: gatekeeper.sh/system: "yes" name: providers.externaldata.gatekeeper.sh spec: group: externaldata.gatekeeper.sh names: kind: Provider listKind: ProviderList plural: providers singular: provider preserveUnknownFields: false scope: Cluster versions: - deprecated: true deprecationWarning: externaldata.gatekeeper.sh/v1alpha1 is deprecated. Use externaldata.gatekeeper.sh/v1beta1 instead. name: v1alpha1 schema: openAPIV3Schema: description: Provider is the Schema for the Provider API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: path_to_url#resources' type: string kind: description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: path_to_url#types-kinds' type: string metadata: type: object spec: description: Spec defines the Provider specifications. properties: caBundle: description: CABundle is a base64-encoded string that contains the TLS CA bundle in PEM format. It is used to verify the signature of the provider's certificate. type: string timeout: description: Timeout is the timeout when querying the provider. type: integer url: description: URL is the url for the provider. URL is prefixed with path_to_url type: string type: object type: object served: true storage: false - name: v1beta1 schema: openAPIV3Schema: description: Provider is the Schema for the providers API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: path_to_url#resources' type: string kind: description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: path_to_url#types-kinds' type: string metadata: type: object spec: description: Spec defines the Provider specifications. properties: caBundle: description: CABundle is a base64-encoded string that contains the TLS CA bundle in PEM format. It is used to verify the signature of the provider's certificate. type: string timeout: description: Timeout is the timeout when querying the provider. type: integer url: description: URL is the url for the provider. URL is prefixed with path_to_url type: string type: object type: object served: true storage: true ```
```go /* path_to_url Unless required by applicable law or agreed to in writing, software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package framework import ( "bytes" "context" "crypto/rand" "crypto/rsa" "crypto/tls" "crypto/x509" "crypto/x509/pkix" "encoding/pem" "fmt" "io" "math/big" "net" net_url "net/url" "strings" "time" "github.com/onsi/ginkgo/v2" "github.com/stretchr/testify/assert" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" ) const ( rsaBits = 2048 validFor = 365 * 24 * time.Hour ) // CreateIngressTLSSecret creates or updates a Secret containing a TLS // certificate for the given Ingress and returns a TLS configuration suitable // for HTTP clients to use against that particular Ingress. func CreateIngressTLSSecret(client kubernetes.Interface, hosts []string, secretName, namespace string) (*tls.Config, error) { if len(hosts) == 0 { return nil, fmt.Errorf("require a non-empty host for client hello") } var serverKey, serverCert bytes.Buffer var data map[string][]byte host := strings.Join(hosts, ",") if err := generateRSACert(host, true, &serverKey, &serverCert); err != nil { return nil, err } data = map[string][]byte{ v1.TLSCertKey: serverCert.Bytes(), v1.TLSPrivateKeyKey: serverKey.Bytes(), } newSecret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: secretName, }, Data: data, } var apierr error curSecret, err := client.CoreV1().Secrets(namespace).Get(context.TODO(), secretName, metav1.GetOptions{}) if err == nil && curSecret != nil { curSecret.Data = newSecret.Data _, apierr = client.CoreV1().Secrets(namespace).Update(context.TODO(), curSecret, metav1.UpdateOptions{}) } else { _, apierr = client.CoreV1().Secrets(namespace).Create(context.TODO(), newSecret, metav1.CreateOptions{}) } if apierr != nil { return nil, apierr } serverName := hosts[0] return tlsConfig(serverName, serverCert.Bytes()) } // CreateIngressMASecret creates or updates a Secret containing a Mutual Auth // certificate-chain for the given Ingress and returns a TLS configuration suitable // for HTTP clients to use against that particular Ingress. func CreateIngressMASecret(client kubernetes.Interface, host, secretName, namespace string) (*tls.Config, error) { if host == "" { return nil, fmt.Errorf("requires a non-empty host") } var caCert, serverKey, serverCert, clientKey, clientCert bytes.Buffer var data map[string][]byte if err := generateRSAMutualAuthCerts(host, &caCert, &serverKey, &serverCert, &clientKey, &clientCert); err != nil { return nil, err } data = map[string][]byte{ v1.TLSCertKey: serverCert.Bytes(), v1.TLSPrivateKeyKey: serverKey.Bytes(), "ca.crt": caCert.Bytes(), } newSecret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: secretName, }, Data: data, } var apierr error curSecret, err := client.CoreV1().Secrets(namespace).Get(context.TODO(), secretName, metav1.GetOptions{}) if err == nil && curSecret != nil { curSecret.Data = newSecret.Data _, apierr = client.CoreV1().Secrets(namespace).Update(context.TODO(), curSecret, metav1.UpdateOptions{}) } else { _, apierr = client.CoreV1().Secrets(namespace).Create(context.TODO(), newSecret, metav1.CreateOptions{}) } if apierr != nil { return nil, apierr } clientPair, err := tls.X509KeyPair(clientCert.Bytes(), clientKey.Bytes()) if err != nil { return nil, err } return &tls.Config{ ServerName: host, Certificates: []tls.Certificate{clientPair}, InsecureSkipVerify: true, //nolint:gosec // Ignore the gosec error in testing }, nil } // WaitForTLS waits until the TLS handshake with a given server completes successfully. func WaitForTLS(url string, tlsConfig *tls.Config) { //nolint:staticcheck // TODO: will replace it since wait.Poll is deprecated err := wait.Poll(Poll, DefaultTimeout, matchTLSServerName(url, tlsConfig)) assert.Nil(ginkgo.GinkgoT(), err, "waiting for TLS configuration in URL %s", url) } // generateRSACert generates a basic self signed certificate using a key length // of rsaBits, valid for validFor time. func generateRSACert(host string, isCA bool, keyOut, certOut io.Writer) error { priv, err := rsa.GenerateKey(rand.Reader, rsaBits) if err != nil { return fmt.Errorf("failed to generate key: %v", err) } notBefore := time.Now() notAfter := notBefore.Add(validFor) serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) if err != nil { return fmt.Errorf("failed to generate serial number: %s", err) } template := x509.Certificate{ SerialNumber: serialNumber, Subject: pkix.Name{ CommonName: "default", Organization: []string{"Acme Co"}, }, NotBefore: notBefore, NotAfter: notAfter, KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, BasicConstraintsValid: true, } hosts := strings.Split(host, ",") for _, h := range hosts { if ip := net.ParseIP(h); ip != nil { template.IPAddresses = append(template.IPAddresses, ip) } else { template.DNSNames = append(template.DNSNames, h) } } if isCA { template.IsCA = true template.KeyUsage |= x509.KeyUsageCertSign } derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) if err != nil { return fmt.Errorf("failed to create certificate: %s", err) } if err := pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}); err != nil { return fmt.Errorf("failed creating cert: %v", err) } if err := pem.Encode(keyOut, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}); err != nil { return fmt.Errorf("failed creating key: %v", err) } return nil } // generateRSAMutualAuthCerts generates a complete basic self-signed certificate-chain (ca, server, client) using a // key-length of rsaBits, valid for validFor time. func generateRSAMutualAuthCerts(host string, caCertOut, serverKeyOut, serverCertOut, clientKeyOut, clientCertOut io.Writer) error { notBefore := time.Now() notAfter := notBefore.Add(validFor) serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) if err != nil { return fmt.Errorf("failed to generate serial number: %s", err) } // Generate the CA key and CA cert caKey, err := rsa.GenerateKey(rand.Reader, rsaBits) if err != nil { return fmt.Errorf("failed to generate key: %v", err) } caTemplate := x509.Certificate{ Subject: pkix.Name{ CommonName: host + "-ca", Organization: []string{"Acme Co"}, }, SerialNumber: serialNumber, NotBefore: notBefore, NotAfter: notAfter, KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, BasicConstraintsValid: true, } caTemplate.IsCA = true caTemplate.KeyUsage |= x509.KeyUsageCertSign caBytes, err := x509.CreateCertificate(rand.Reader, &caTemplate, &caTemplate, &caKey.PublicKey, caKey) if err != nil { return fmt.Errorf("failed to create certificate: %s", err) } if err := pem.Encode(caCertOut, &pem.Block{Type: "CERTIFICATE", Bytes: caBytes}); err != nil { return fmt.Errorf("failed creating cert: %v", err) } // Generate the Server Key and CSR for the server serverKey, err := rsa.GenerateKey(rand.Reader, rsaBits) if err != nil { return fmt.Errorf("failed to generate key: %v", err) } // Create the server cert and sign with the csr serialNumber, err = rand.Int(rand.Reader, serialNumberLimit) if err != nil { return fmt.Errorf("failed to generate serial number: %s", err) } serverTemplate := x509.Certificate{ SerialNumber: serialNumber, Subject: pkix.Name{ CommonName: host, Organization: []string{"Acme Co"}, }, NotBefore: notBefore, NotAfter: notAfter, KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, } serverBytes, err := x509.CreateCertificate(rand.Reader, &serverTemplate, &caTemplate, &serverKey.PublicKey, caKey) if err != nil { return fmt.Errorf("failed to create certificate: %s", err) } if err := pem.Encode(serverCertOut, &pem.Block{Type: "CERTIFICATE", Bytes: serverBytes}); err != nil { return fmt.Errorf("failed creating cert: %v", err) } if err := pem.Encode(serverKeyOut, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(serverKey)}); err != nil { return fmt.Errorf("failed creating key: %v", err) } // Create the client key and certificate clientKey, err := rsa.GenerateKey(rand.Reader, rsaBits) if err != nil { return fmt.Errorf("failed to generate key: %v", err) } serialNumber, err = rand.Int(rand.Reader, serialNumberLimit) if err != nil { return fmt.Errorf("failed to generate serial number: %s", err) } clientTemplate := x509.Certificate{ SerialNumber: serialNumber, Subject: pkix.Name{ CommonName: host + "-client", Organization: []string{"Acme Co"}, }, NotBefore: notBefore, NotAfter: notAfter, KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, } clientBytes, err := x509.CreateCertificate(rand.Reader, &clientTemplate, &caTemplate, &clientKey.PublicKey, caKey) if err != nil { return fmt.Errorf("failed to create certificate: %s", err) } if err := pem.Encode(clientCertOut, &pem.Block{Type: "CERTIFICATE", Bytes: clientBytes}); err != nil { return fmt.Errorf("failed creating cert: %v", err) } if err := pem.Encode(clientKeyOut, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(clientKey)}); err != nil { return fmt.Errorf("failed creating key: %v", err) } return nil } // tlsConfig returns a client TLS configuration for the given server name and // CA certificate (PEM). func tlsConfig(serverName string, pemCA []byte) (*tls.Config, error) { rootCAPool := x509.NewCertPool() if !rootCAPool.AppendCertsFromPEM(pemCA) { return nil, fmt.Errorf("error creating CA certificate pool (%s)", serverName) } return &tls.Config{ //nolint:gosec // Ignore the gosec error in testing ServerName: serverName, RootCAs: rootCAPool, }, nil } // matchTLSServerName connects to the network address corresponding to the // given URL using the given TLS configuration and returns whether the TLS // handshake completed successfully. func matchTLSServerName(url string, tlsConfig *tls.Config) wait.ConditionFunc { return func() (bool, error) { u, err := net_url.Parse(url) if err != nil { return false, err } port := u.Port() if port == "" { port = "443" } conn, err := tls.Dial("tcp", fmt.Sprintf("%v:%v", u.Host, port), tlsConfig) if err != nil { Logf("Unexpected TLS error: %v", err) return false, nil } defer conn.Close() return true, nil } } ```
2gether is the debut album by 2gether, released in 2000. It includes the singles, "U + Me = Us (Calculus)", "Say It (Don't Spray It)", and "Before We Say Goodbye". It also contains "2Gether", which later became the theme song for the band's TV show. The name is a Wordplay of the word together. Most of the lyrics were written by the band's creators, Brian Gunn and Mark Gunn. Track listing Singles "U + Me = Us (Calculus)" – released January 2000; did not chart. "Say It (Don't Spray It)" – released April 2000; did not chart. "Before We Say Goodbye" – released June 2000; did not chart. Personnel Evan Farmer – vocals, background vocals, co-writing on "You're My Baby Girl" Noah Bastian – vocals, background vocals Michael Cuccione – vocals, background vocals, co-writing on "Visualize" Kevin Farley – vocals, background vocals Alex Solowitz – vocals, background vocals Nigel Dick – writing Andrew Fromm – writing Brian Gunn – writing Mark Gunn – writing Brian Kierulf – writing Veit Renn – writing Joshua M. Schwartz – writing "Rub One Out" and "Breaking All The Rules" were performed by uncredited vocalists. Charts Album References 2000 debut albums 2gether (band) albums
Harrison McEldowney American choreographer known for his theatrical work, for the 1992 Summer Olympics Closing Ceremonies and for Carnegie Hall's "Give My Regards to Broadway: A Salute to 125 Years of Musical Theater", 17 June 1991. McEldowney was born and grew up in Texas. He is noted for his comic and witty choreography. He choreographed the 35th Anniversary Tour of American Bandstand and choreographed and directed the Australian Tour of More Dirty Dancing. McEldowney has worked with the Hubbard Street Dance Chicago, River North Chicago Dance Company, the Civic Ballet of Chicago, Ballet Met (Columbus),The Big Muddy Dance Company (St. Louis), Louisville Ballet, Chicago Shakespeare Repertory, Chicago Dance Crash, San Antonio Metropolitan Ballet, Ballet of Texas and the Configurations Dance Company where he is currently (Fall 2006) the Resident Choreographer. McEldowney contributed choreography to the films Road to Perdition, Children on Their Birthdays (uncredited), and the independent film Vanilla City. Awards After Dark Award from Gay Chicago Magazine for performance and choreography 1998 Ruth Page Award for choreography 1999 The first Prince Prize (Prince Charitable Trusts, Chicago), commissioning an original work References Weiss, Hedy (1999) "In art, they trust: Three-year plan aids new works" Chicago Sun-Times 7 October 1999, Thursday, Features, p. 48; Davenport, Misha (July 2002) "Choreographer sports new approach" Chicago Sun-Times 28 July 2002, Sunday Show, p. 3; Barzel, Ann (August 2000) "Hubbard Finds Firm Footing" Dance Magazine 74(8): p. 72.; External links "Guest Artists Fall 2006: Harrison McEldowney" Theatre & Dance College of Fine Arts, University of Texas at Austin; "Harrison McEldowney, choreographer" BalletNotes BalletMet Columbus, Columbus Ohio; "Harrison McEldowney" Civic Ballet of Chicago, Chicago, Illinois; American choreographers American male dancers Living people Year of birth missing (living people)
The Omaha Fire Department Hose Company building is a historic building located at 999 North 16th Street in Omaha, Nebraska, United States. The former home of Omaha Fire Department's hose company number 4 and designed by German-born architect Joseph P. Guth and built in 1913 by Dutchman Peter Kiewit & Sons, the building is now unoccupied. Charles A. Salter was the chief of the fire department at the time. In 2011, the Nebraska State Historical Society included the building in its Reconnaissance Survey of Downtown and Columbus Park Omaha, which was prepared for the City of Omaha. The building has served as the home of horse-drawn fire wagons, a plumbing company, an auto transmission shop, an armored car garage and, its last known use, for storage. See also History of Omaha, Nebraska References Fire stations completed in 1913 Buildings and structures in Omaha, Nebraska Defunct fire stations in Nebraska 1913 establishments in Nebraska Landmarks in North Omaha, Nebraska
The Thracian question is the question of the territory, population and historical heritage of Thrace. The Thracian question is part of the Eastern Question. History The Thracian question is an integral part of the Bulgarian national question and is a conditional indication of the struggle of the Bulgarians from Thrace to liberate them from Ottoman domination. The successful completion of the Eastern Rumelia Union with the Principality of Bulgaria in 1885 gave the struggling Thracians the hope that they would be able to achieve their liberation. They took an active part in the Ilinden–Preobrazhenie Uprising in 1903. References Любомир Милетич Разорението на тракийските българи през 1913 г. София,1989 19th century in the Ottoman Empire History of Thrace 20th century in the Ottoman Empire
Hossein Tala () is an Iranian conservative politician who was formerly a member of the Parliament of Iran representing Tehran, Rey, Shemiranat and Eslamshahr. References 1969 births Living people Members of the 9th Islamic Consultative Assembly Deputies of Tehran, Rey, Shemiranat and Eslamshahr Front of Islamic Revolution Stability politicians
Feel the Beat is a 2020 American family dance comedy-drama film directed by Elissa Down, written by Michael Armbruster and Shawn Ku and starring Sofia Carson, Enrico Colantoni and Wolfgang Novogratz. Plot April Dibrina, a young dancer seeking success on Broadway, steals a cab from an old lady during a rainstorm to get to an audition. She performs well, but sponsor Ruth Zimmer, meets the potential dancers. When she recognizes April (from the taxi incident), she vows that no one on Broadway will hire her. While trying to explain, she accidentally knocks Ruth off stage, inflicting serious injury. It is posted on social media, publicly embarrassing April. Evicted, April returns to her hometown in Wisconsin. While at the grocery store, she bumps into the New Hope dance teacher Miss Barb, who invites her to come to the dance studio. April also sees her ex Nick, whom she left to pursue a career in New York City. In the dance studio, she visits the class of dancers: Lucia, a forgetful girl with glasses; Oona, a nervous girl; Kari, who secretly earns her own classes; Ruby, with no self-confidence; Zuzu, a deaf girl; June, Miss Barb's daughter; Sarah, Nick’s stubborn little sister; and Michelle, Nick’s other little sister and the youngest. Zuzu’s little brother, Dicky, also watches. Barb asks April to coach the town's dance team for a competition. At first, she declines, but later realizes it can give her a chance to perform in front of Welly Wong, saving her career. April accepts, beginning a harsh training regimen that alienates the young dancers, including causing Ruby to quit. The New Hope dance team advances through several rounds of the competition; they improve as April bonds with them, becoming a better teacher, including learning some sign language to communicate with Zuzu. One day, the dance studio ceiling collapses after April tells the dancers they "don't suck," so they know they are improving. Unable to afford repairs to the studio, the team moves practice to the football field and eventually move to April's father's barn, which Nick has helped repair. April and Nick begin to rekindle their relationship as the dance team advances to state. Dancers from another troupe taunt her about her failure in New York, causing her to lose focus during one dance, though she recovers. In the mini’s 6-and-under category, the two youngest dancers, June and Michelle, are struck with stage fright. Dicky, who has memorized all the girl's choreography while they practiced, runs out and starts to dance. June and Michelle recover, and they all dance together. Dicky now trains with the dance troupe. After passing state finals, April calls her NYC friend Deco to help make costumes. One day, as the small dancers are rehearsing a lift in the barn, April calls on Sarah and R.J., the football player whom Sarah has a crush and she wants to impress, to demonstrate. When R.J. lifts her, her silicone bra cup falls on the floor, and she runs off, embarrassed and crying. April finds her in the field and comforts her. The dancers' families raise the money to send the team to Atlantic City for the finals. April reconnects with Nick's younger sister Sarah, who had felt abandoned when her mother died and April moved to New York. Once in Atlantic City, after a performance, Welly Wong is so impressed with April he offers her the lead in his new show on the spot. April and Welly leave the competition immediately for rehearsal in NYC, devastating the team. The next day, April realizes her mistake and abandons the rehearsal, proclaiming to Welly that she must honor her commitment to New Hope. She calls Deco again to drive her back to Atlantic City just in time to encourage the team before the performance. After reconciling with her dancers, April and Nick kiss, and Welly keeps her on despite leaving rehearsal. April performs in Welly Wong's show in NYC and continues teaching her dance class in Wisconsin via video chat. On opening night, Welly surprises April by bringing the New Hope team over for a dance party. Everyone dances in the street, and Ruth Zimmer drives by momentarily, appalled. Cast Release Feel the Beat was released on June 19, 2020. Reception Review aggregator Rotten Tomatoes reported an approval rating of based on reviews, with an average rating of . Soundtrack "Let's Do It" - All Talk "Work Dat (So Dat)" - Kylie Diehl "Hand of Man" - Country Joe & The Fish "Round and Round" - Jack Hawitt "Brand New Day" - Kari Kimmel "Never Forgive You" - Brooke Villanyi "Wish You Was Me" - Lauren Evans "Glitter Shoes" - Blaire Reinhard "Confident" - Demi Lovato "Us" - Regina Spektor "Deal With It" - Girli "Pumpin Blood" - NoNoNo "Yes or Yes" - Tricia Battani "I'm Gonna Do My Thing (Hey Hey)" - Mozella "Like That" - Fleur East "Colors" - Wayfarers "Follow the Leader" - Wayfarers "Winner Won't Stop" - Neara Russell "Always" (Acoustic) - Francois Klark "A Little More" - Alessia Cara "Gonna Make You Sweat (Everybody Dance Now)" - C+C Music Factory "All I Wanna Do Is Dance" - Mozella "Always" - Sofia Carson See also List of films featuring the deaf and hard of hearing References External links 2020 films American comedy-drama films American dance films Films about dance competitions Films about deaf people Films set in Atlantic City, New Jersey Films set in New York City Films set in Wisconsin Films shot in Toronto English-language Netflix original films Films scored by Michael Yezerski 2020s English-language films Films directed by Elissa Down 2020s American films Films about disability
The 5th constituency of Bács-Kiskun County () is one of the single member constituencies of the National Assembly, the national legislature of Hungary. The constituency standard abbreviation: Bács-Kiskun 05. OEVK. Since 2014, it has been represented by Gábor Bányai of the Fidesz–KDNP party alliance. Geography The 5th constituency is located in south-eastern part of Bács-Kiskun County. List of municipalities The constituency includes the following municipalities: Members The constituency was first represented by Gábor Bányai of the Fidesz from 2014, and he was re-elected in 2018 and 2022. References Bács-Kiskun 5th
La Fère () is a commune in the Aisne department in Hauts-de-France in France. Population See also Communes of the Aisne department References Communes of Aisne Aisne communes articles needing translation from French Wikipedia
Alexander Eric McAllister (born 19 December 1920) is a Scottish former cricketer, who played one first-class match for the Scotland cricket team in 1950. McAllister played his domestic cricket for Clydesdale Cricket Club in Glasgow, captaining the team from 1950 to 1952. Upon the death of Archie Scott in November 2019, McAllister became the oldest living person to have played cricket for Scotland. References External links 1920 births Living people Scottish cricketers Sportspeople from Paisley, Renfrewshire Scottish centenarians Men centenarians
```java Use meaningful names Common mistake on switch statements Altering format string output by changing a format specifier's `argument_index` Updating interfaces by using `default` methods Supply `toString()` in all classes ```
Karolina Sofia Bock née Richter (August 28, 1792, Stockholm – 22 March 1872) was a Swedish stage actress. She was the principal and drama teacher of the Royal Dramatic Training Academy twice: from 1831 to 1834, and from 1841 to 1856. She was an elite actress of the Royal Dramatic Theatre. Life Karolina Richter was born to the hautboist Carl Johan Richter and Magdalena Sofia Rytting. She was a student of the Royal Dramatic Training Academy at the Royal Swedish Opera between 1806 and 1810. She was a student of Sofia Lovisa Gråå, and belonged to those female stage artists of her generation referred to as the "Grå Girls". Early life Karolina Bock was engaged at the Djurgårdsteatern and the Nya komiska teatern of Isak de Broen in 1813-14. In 1814, she was engaged at the Royal Dramatic Theatre, where she remained active until her retirement on 26 June 1863. Karolina Bock came to belong to the elite of Swedish actors generation. She was not regarded suitable for heroine parts, which were often the main female roles of the plays of the epoch, but established herself well already in her youth in the roles of old women in comedies, a category in which she formed a successful career and never lacked assignments, becoming: "...an often used and well seen actress, who never spoiled a part but were terrific in most and always gave her figures a sharply lined characteristic. :Particularly in her interpretation of old women's parts she developed in to a talent of the first order." It was said of her that she had a rare quality: she knew her own limitations. Among her most successful roles were the title role in Min tante Aurore by Boieldieu, Veneranda in Slottet Montemero, Mrs Slammerström in Bildhuggaren, Aunt Vivika in General Eldhjelm, Mrs Griponiai in Brodertvisten by Kotzebue, Mrs Miller in Kabal och kärlek, Viarda in Preciosa, Mrs von Fromuth i Porträttet, Mrs Wunschell in Grefvarne Klingsberg, Theodolinda in Doktor Wespe, Mrs Darmantiéres in Dottersonen, Margarita in Mazarin, Fadette in Syrsan (the dramatisation of La Petite Fadette by George Sand), Mrs Malapropp in Rivalerna, Mrs Harleigh in Jane Eyre and Gunilla Fipps in Mäster Smith. On 26 June 1863, Bock retired after having made her final performance in her favorite part, the grandmother in Porträttet. Karolina Bock was given the Litteris et Artibus by the king in 1857, in recognition of her dramatic career. Educator Karolina Bock was the principal and drama teacher of the Royal Dramatic Training Academy twice: from 1831 to 1834 and from 1841 to 1856. She also served as instructor of declamation there. Several generations of Swedish actors were shaped by Bock. Among her students were Emilie Högquist and Jenny Lind. Her method was that of the French technique which had been introduced at the school by Anne Marie Milan Desguillons and kept at the time of her own tenure as student there under Sofia Lovisa Gråå. She was known for her skill at giving instruction in the correct distinction of the language in both song and speech, and it was said that all of her students were recognizable by having the distinction taught during her tenure. Her technique, however, belonged to the elder French school of solemnity which was replaced by the new romantic schools more natural acting by the mid-19th century. Furthermore, though Karolina Bock was described as an excellent teacher, she was also described as one who forced a more strict discipline upon her students, and in 1856, she was deposed as principal after protests by the acting class. The "Bock Woman" was described as a "theatre original" with a fierce temperament. When she was given the task to instruct the Danish guest artist Charlotte Bournonville (daughter of August Bournonville) in the Swedish language in 1857, she performed the task so well that Bournonville could perform soon after as a native Swede in the part of Fatima in Oberon, where she made success. When the direction thanked Bock for this, she "gave them such a load of barking that they quickly retreated." Personal life Karolina Bock was married twice. In 1813, she married Johan Gabriel Svanberg violinist at the royal chapel, from whom she divorced in 1822, assuming the name Mrs Richter. In 1826 she married Carl Friedrich Bock, who played the flute in the royal chapel. She was the mother of Bertha Tammelin, who became an actor, singer, composer, musician and a teacher at the Royal Dramatic Training Academy. References Nordisk familjebok Nordisk familjebok (Swedish) Österberg, Carin et al., Svenska kvinnor: föregångare, nyskapare ['Swedish women: Predecessors, Pioneers']. Lund: Signum 1990. ()(Swedish) Wilhelmina Stålberg, Anteqningar om svenska qvinnor ['Notes on Swedish women'] (Swedish) Svenska män och kvinnor ['Swedish men and women'] Dictionary (Swedish) Nordensvan, Georg, Svensk teater och svenska skådespelare från Gustav III till våra dagar. Förra delen, 1772-1842, Bonnier, Stockholm, 1917 ['Swedish theatre and Swedish actors from Gustav III to our days. First Book 1772–1842'] Löfgren, Lars, Svensk teater, Natur och kultur, Stockholm, 2003 (in Swedish)(Swedish) 1792 births 1872 deaths 19th-century Swedish actresses Swedish stage actresses Drama teachers Litteris et Artibus recipients
Thomas Danneberg (2 June 1942 – 30 September 2023) was a German actor. He is best known as Charles Emerson in the 1967 Edgar Wallace film The Blue Hand and for dubbing over the actors Arnold Schwarzenegger, Terence Hill, Sylvester Stallone, John Cleese, Dan Aykroyd, Adriano Celentano, Nick Nolte, John Travolta, Michael York, Rutger Hauer and Dennis Quaid. Danneberg also collaborated with the German trance/techno-band E Nomine on a number of their albums. Thomas Danneberg retired from voice acting because of health reasons. He died from a stroke on 30 September 2023, at the age of 81. Filmography Films Codename: Wildgeese – 1985 – Habib Commando Leopard – 1986 – Jose – 1988 – "Crazy Bo" Gustafsson Television animation A Sitch in Time (Rufus 3000) Original video animation Mickey's Twice Upon a Christmas (Blitzen) Theatrical animation Big Hero 6 (Heathcliff) Brother Bear (Tuke) Chicken Little (Hollywood Chicken Little) Igor (Dr. Glickenstein) Shark Tale (Luca) Shrek 2 (King Harold) Shrek Forever After (King Harold) Shrek the Third (King Harold) The Fox and the Hound (Adult Tod) The Wild (Benny) Video games Ankh (Annoying Palace Guard, Mummy, Souvenir Dealer) Jack Keane (Montgomery) Dubbing roles (live action) Dan Aykroyd John Cleese Terence Hill Dennis Quaid Arnold Schwarzenegger Sylvester Stallone John Travolta Die Hard with a Vengeance (John McClane) The Fall Guy (Howie Munson) Highlander (The Kurgan) Hulk (David Banner) Mother, Jugs & Speed (Murdoch) Audiobooks 2007: John Katzenbach: Die Anstalt, The Madman's Tale (together with Simon Jäger), publisher: Argon Verlag, References External links German Dubbing Card Index 1942 births 2023 deaths German male film actors German male video game actors German male voice actors Male actors from Berlin
Poor Little Bitch Girl is the 27th novel by English novelist Jackie Collins. It was released on 4 October 2009 in the United Kingdom, and 9 February 2010 in the United States. The book stemmed from an idea that Collins was working on for a television series about heiresses entitled Poor Little Rich Girls. The series was ultimately never made and so she adapted the material for a novel. References Novels by Jackie Collins 2009 British novels Simon & Schuster books
Labra is a surname. Notable people with the surname include: Armando Labra (1943–2006), Mexican economist Berting Labra (1933–2009), Filipino actor Carilda Oliver Labra (1922–2018), Cuban poet Carlos Fernando Flores Labra (born 1943), Chilean engineer, entrepreneur and politician Onofre Jarpa Labra (1849–1940), Chilean landscape painter Patricia Labra (born 1986), Chilean lawyer Rafael María de Labra (1840–1918), Spanish educator and politician Spanish-language surnames
```javascript // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // A JavaScript implementation of the RSA Data Security, Inc. MD5 Message // Digest Algorithm, as defined in RFC 1321. // Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet // See path_to_url for more info. // function hex_md5(s) { return binl2hex(core_md5(str2binl(s), s.length * 8)); } function core_md5(x, len) { /* append padding */ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for (var i = 0; i < x.length; i += 16) { var olda = a; var oldb = b; var oldc = c; var oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = safe_add(a, olda); b = safe_add(b, oldb); c = safe_add(c, oldc); d = safe_add(d, oldd); } return Array(a, b, c, d); } function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); } function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); } function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); } function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); } function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); } function safe_add(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function bit_rol(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); } function str2binl(str) { var bin = Array(); var mask = (1 << 8) - 1; for(var i = 0; i < str.length * 8; i += 8) bin[i>>5] |= (str.charCodeAt(i / 8) & mask) << (i%32); return bin; } function binl2hex(binarray) { var hex_tab = "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; } var plainText = "Rebellious subjects, enemies to peace,\n\ Profaners of this neighbour-stained steel,--\n\ Will they not hear? What, ho! you men, you beasts,\n\ That quench the fire of your pernicious rage\n\ With purple fountains issuing from your veins,\n\ On pain of torture, from those bloody hands\n\ Throw your mistemper'd weapons to the ground,\n\ And hear the sentence of your moved prince.\n\ Three civil brawls, bred of an airy word,\n\ By thee, old Capulet, and Montague,\n\ Have thrice disturb'd the quiet of our streets,\n\ And made Verona's ancient citizens\n\ Cast by their grave beseeming ornaments,\n\ To wield old partisans, in hands as old,\n\ Canker'd with peace, to part your canker'd hate:\n\ If ever you disturb our streets again,\n\ Your lives shall pay the forfeit of the peace.\n\ For this time, all the rest depart away:\n\ You Capulet; shall go along with me:\n\ And, Montague, come you this afternoon,\n\ To know our further pleasure in this case,\n\ To old Free-town, our common judgment-place.\n\ Once more, on pain of death, all men depart.\n" for (var i = 0; i < 4; ++i) { plainText += plainText; } assertEquals(hex_md5("abc"), "900150983cd24fb0d6963f7d28e17f72"); for (var i = 0; i < 11; ++i) { assertEquals(hex_md5(plainText), "1b8719c72d5d8bfd06e096ef6c6288c5"); } ```
Jokkmokk (; or ; ; ) is a locality and the seat of Jokkmokk Municipality in Norrbotten County, province of Lapland, Sweden, with 2,786 inhabitants in 2010. The Lule Sami name of the place (composed of the individual words and ) means "River's Curve," due to the meandering river that runs through it. As in other towns in Lapland, the Swedish language is dominant at an official level in Jokkmokk in modern times. The settlement is just north of the Arctic Circle. Talvatissjön is located at the southern part of Jokkmokk. Jokkmokk is an important locality for Sámi people and the location of several institutions related to them, including an education centre, the Ájtte museum, and an office of the Sámi Parliament of Sweden. Jokkmokk was a transit center for Sami refugees from Norway during World War II, in addition to the centre in Kjesäter. Jokkmokk Market has been taking place since 1605. On the first Thursday in February every year, thousands of people gather in the town for concerts, exhibitions and trade in one of the most important social events for the Sámi people in Sápmi. Temperatures during the festival can drop as low as . Climate Influenced by its inland and northerly position, Jokkmokk's variety of a subarctic climate (Dfc) is very cold by Swedish standards. Summers are normally relatively mild, with midnight sun, and the dark winters are long and cold, although polar night is not quite observed with a sun angle of 0.4° at the winter solstice. Combining an elevation of with being at the foot of the Scandinavian Mountains, Jokkmokk is both cooled down during the day and experiences temperature inversion during night. This combination makes it the coldest municipal seat in Sweden in terms of winter temperatures, although some rural localities in Lapland are even colder. See also Kåbdalis References External links Tourist information in Jokkmokk Ájtte Museum of Sami people Populated places in Jokkmokk Municipality Lapland (Sweden) Municipal seats of Norrbotten County Swedish municipal seats Populated places in Arctic Sweden
Spottswood Rice (November 1819 – October 31, 1907) was a minister in the African Methodist Episcopal (AME) church and a private in the Union Army during the US Civil War. Rice is most famous for a pair of forcefully written letters to the owner of his wife and children during the war while he was stationed in St. Louis and they were enslaved in Howard County, Missouri. The letters expressed his desire to be reunited with his family and his anger at his wife's owners. Later, he was ordained a minister in the AME church and served congregations in Missouri, New Mexico, and Colorado. In 1882, he founded the first AME church in New Mexico. Early life Spottswood Rice was born a slave in Madison County, Virginia in November 1819. At a very early age his owner moved with his parents to Howard County, Missouri. In Missouri, Rice married Arry or Orry Ferguson. As it was a slave marriage, the exact date was not well recorded and may have been in 1852 or in July 1844. Arry was born in Fauquier County, Virginia, and they had seven or eight children, at least five of which reached adulthood. One son was killed in the civil war, another died in St. Louis in 1919, and the third died in Colorado Springs in October 1925. One daughter, Mary, was born in Missouri on May 1, 1852 and married in 1882. Mary was interviewed and provided a slave narrative for the Works Progress Administration Writer's Program. Slavery Before emancipation, Rice's wife and all of his children were owned by a single woman named Kitty Diggs. Rice was owned by a tobacco plantation owner named Benjamin Lewis, where Rice was the head slave on the plantation, and cured and rolled the tobacco. Lewis' son taught Rice to read, to the chagrin of the elder Lewis. He was only allowed to visit Arry and his family two days a week, Wednesdays and Saturdays. He was frequently beaten by his owner. One time he tried to escape. During his escape, he hid in the woods and under houses, but after three days he gave up. He turned himself in to a slave trader he knew who promised to buy him from Lewis. However, Lewis would not sell Rice, and he was forced to remain on the plantation. The Emancipation Proclamation was published January 1, 1863. Rice read about it in the newspapers to the other slaves on the Lewis plantation. Lewis greatly valued Rice on the plantation: in fact, he tried to convince Rice to stay and run the farm and to convince the other slaves to stay as well. Rice remained for six months, but then left the plantation with eleven other slaves and joined the Union Army in Kansas City. Patrols hunting for Lewis' slaves were turned away when they approached the Union camps, as they were no longer slaves but were Union soldiers. Civil War Rice enlisted on February 9, 1864, near Glasgow, Missouri, joining as a private in Company A of the 67th United States Colored Infantry Regiment. During parts of his service, Rice was hospitalized at Benton Barracks near St. Louis, Missouri for chronic rheumatism. While there in September 1864, Rice wrote two letters, one to his daughters who were still enslaved in Howard County and the other to Kitty Diggs, their owner. He wrote passionately of his desire to free them, writing, "be assured that I will have you if it cost me my life." In defiance of Diggs' wish to keep the girls, he said, "She is the first Christian that I ever heard say that a man could steal his own children, especially out of human bondage." He believed that 800 white and 800 black Union soldiers would come to the plantation and rescue them. Kitty's brother, F. W. Diggs wrote to General Rosecrans, then commander of the Department of the Missouri, arguing that Kitty's loyalty should guarantee the children remaining her slaves. Rice was a very religious man, and his obituary notes he was a chaplain in the Army. It is unclear if this was an official designation. Rice was mustered out of service in May, 1865 and continued to live in St. Louis. Immediately after the war, Rice worked as a nurse at Benton Barracks and his wife was a laundress. His children attended their first schools on Benton Barracks, but later attended newly created schools for blacks in the city. Ministry He joined the African Methodist Church of St. Louis, and became licensed as a local preacher, being ordained deacon in 1870 or 1874. In 1871, he had charge of the Savannah, Missouri Mission. He was ordained an Elder in 1876, when he was pastor of the Washington, Missouri Circuit. In 1879 he was transferred to Canton, Missouri. In 1881 he was pastor of St. Peter's Chapel, in St. Louis. In 1882 he was transferred to the State Line Church, in Kansas City, Missouri, a part of the Kansas Congress. In October, 1882, he was appointed to pastor of the church at Parsons, Kansas. Later in the 1880s, Rice founded the first AME mission in New Mexico which became Grant Chapel AME. On March 19, 1888, Arry died. Rice later remarried. By 1901, he had moved to Colorado Springs where he founded another church. Rice died on October 31, 1907. References 1907 deaths People from Madison County, Virginia People from Howard County, Missouri Clergy from St. Louis People from Colorado Springs, Colorado People of Missouri in the American Civil War African Americans in the American Civil War African-American activists People of the African Methodist Episcopal church United States Army chaplains African Methodist Episcopal Church clergy 1819 births 19th-century American clergy
William Keith Burge (known as Keith Burge and born 10 August 1950) is a Welsh former football referee. He officiated in the English Football League and Premier League, and for FIFA. He hails from Tonypandy in the county borough of Rhondda Cynon Taff, Glamorgan. His other occupation is as a civil servant. Career He was appointed as a referee to the Football League in 1986, at the age of thirty-five - the last Welsh referee to join the English list, as this option was withdrawn by UEFA in 1997. He was on the first list of referees to officiate in the new Premier League for the 1992-93 season, and made his debut there on 5 September 1992, taking charge of the 3-2 win by Wimbledon over Arsenal at Plough Lane. He was a FIFA official until 1995, when he reached the international retirement age of forty-five. One of his last appointments was in the Euro '96 qualifying tournament, when Lithuania drew 0-0 at home to Croatia on 29 March 1995. Domestically, he retained his place on the Premier League list for six seasons, until he retired from refereeing completely after his final match in the Premier League, a 2-1 win by Manchester United over Aston Villa at Old Trafford on 1 May 1999. References External links Keith Burge Referee Statistics at soccerbase.com (incomplete) 1950 births Welsh football referees Premier League referees People from Tonypandy Sportspeople from Rhondda Cynon Taf Living people
Zvi Hecker (; 31 May 1931 – 24 September 2023) was a Polish-born Israeli architect. His work is known for its emphasis on geometry and asymmetry. Biography Zvi Hecker was born as Tadeusz Hecker in Kraków, Poland. He grew up in Poland and Samarkand. He began his education in architecture at the Cracow University of Technology. He immigrated to Israel in 1950. There he studied architecture at the Technion - Israel Institute of Technology, graduating in 1955. At the Technion, Eldar Sharon was a classmate, and Alfred Neumann was their professor. Between 1955 and 1957, he studied painting at the Avni Institute of Art and Design, before beginning his career as an architect. Between 1957 and 1959, Hecker served in the Combat Engineering Corps of the Israel Defense Forces. Hecker died on 24 September 2023, at the age of 92. Architectural career After his military service, he founded a firm with Eldar Sharon (until 1964) and Alfred Neumann (until 1966). The physical and economic conditions in Israel at the time, allowed them to complete a fair number of works in a relatively brief period of time, which brought international attention. Their joint works include the Mediterranean Sea Club in Achzib (1960–1961), Dubiner House (1963), the Chaim Laskov Officer Training School (1963–1967) Bahad 1, the main officer training school of the Israel Defense Forces, just later the synagogue (1969–1971) at the same academy, and the Bat Yam city hall (1963–1969). Their designs shared aspects in common with the metabolist movement, borrowing metaphoric shapes from nature for use in planning morphological structures. The modularity of these works, such as the Dubiner House, provided an architectural precedent for the Habitat 67 project by Moshe Safdie. Hecker resided in Berlin and Tel Aviv. He was involved in planning projects for the German Jewish community as well as other international projects. Academic career Hecker taught in Canada, the United States, Israel, and Austria at the Université Laval, University of Texas at Arlington, Washington University in St. Louis, Iowa State University, Technion – Israel Institute of Technology, and the University of Applied Arts Vienna. Zvi Hecker wrote about his work periodically, co-authoring books with Sir Peter Cook, John Hejduk, and others. Projects The early projects of Zvi Hecker, designed in partnership with Sharon and Neumann, have architectural qualities that were developed later in his career. The officer school (Bahad 1) was built to give a respectable living environment to soldiers in the Negev desert, and special emphasis was given to the large spaces between the structures, in order to form a micro-environment there, separating the people inside from the harsh desert outskirts. Raw concrete was chosen because it did not require constant maintenance and renovation in light of the strong sandy winds. About the school, Hecker said: "The location of the base has a special relevance to the vision of David Ben-Gurion. To build such an important school in a place which isn't the center of the country – in my opinion, that's the positive side of the State of Israel". The academy was supplemented later with a synagogue, whose form was complementary and contrasting. The Oxford Dictionary of Architecture and Landscape Architecture says of the architect's approach to its design, "Eschewing the right angles of international modernism, he turned to crystalline geometry found in nature [...]" Another of the Zvi Hecker's projects in partnership, the Bat Yam City Hall shows the recurrence of geometrical invention that exists throughout his work. One architectural significance of the Bat Yam City Hall- its formal concept, is that it is an inverted pyramid. It is linked to other works of architecture such as Boston City Hall through this form, in addition to their program, similar materials, and time period. The building is patterned on a diagonal grid with concrete, which provides both its structure and aesthetics. The importance of this building was recognized in 1975 with perspective and section illustrations on a postage stamp in the Architecture in Israel series. As of 2003, Bat Yam City Hall was removed of its signature light shafts, rather than having them renovated. This was because of a perceived structural instability due to weathering over time. Of this removal Dr. Ami Ran wrote, "From an architectural standpoint, removing them is equivalent to dousing the Statue of Liberty's torch." Among several projects for memorials, Zvi Hecker designed the solemn Page Memorial (1996) with Micha Ullmann and Eyal Weizman. This site-specific memorial commemorates the Jewish community of Kreuzberg, and their Lindenstrasse synagogue which was designed in 1891 by architects Cremer & Wolffenstein. What was once one of the largest religious buildings in Berlin, with a capacity of 1800; was ruined by the Nazis in the 1938 Kristallnacht pogrom. On the original floor plan, the benches of the synagogue were recreated in concrete, and where the bimah stood, trees are now planted. The designers conceived of the benches as sentences on the pages of the Talmud. Architectural style Zvi Hecker architecture has continued to emphasize geometry and modularity, but with increasing asymmetry. Ramot Polin (1972–75) is a rare prefabricated apartment complex with 720 non-rectangular components. The apartments were expanded later, incorporating more cubic rather than pentagonal components. The design idea of this neighborhood may seem to be the more purely geometrical, however it is likened to a chemical structure, and in plan view to an open hand, and a leaf- therefore imparting it with metaphorical qualities. More examples of advanced geometry in Hecker's work are the Spiral Apartment House in Ramat Gan, (1981–1989), and the Heinz-Galinski-Schule (1992–1995) in Berlin, noted for their high degree of complexity. The Heinz-Galinski-Schule won Zvi Hecker the Deutscher Kritikerpreis in 1995- it was stated that the decision of the jury was based on their appreciation of the "expressive geometry of his construction." The Spiral Apartment House is located adjacent to his earlier Dubiner house, providing a juxtaposition of two important moments in his career. The work of Zvi Hecker has been compared to that of Antoni Gaudí, for expressiveness and expanding of architectural ideas. More of his later works are the Jewish community center in Duisburg (1996–1999), and with Rafi Segal, the Palmach Museum in Tel Aviv (1995–2000). The Duisburg Jewish community center is located on a park, the Garten der Erinnerung designed by Dani Karavan. The community center shares a similar concept to the Page Memorial in its likening to the open pages of a book, and symbolically the Torah of Moses. The Palmach Museum has an angular zig-zag plan positioned around the preservation of trees on the site. It is clad in a local sandstone that was found in excavations for the project. It was exhibited at the Venice Biennale. Museum exhibits Hecker was the subject of a solo exhibition at the Israel Museum in 1976. He had solo exhibitions at the Tel Aviv Museum of Art in the 1980s and in 1996. He also took part in the Jewish Identity in Contemporary Architecture at the Jewish Museum Berlin in 2005, and participated in the Venice Biennale on a number of occasions. References External links Zvi Hecker | Architect | Berlin 1931 births 2023 deaths Israeli architects Israeli people of Polish-Jewish descent Polish emigrants to Israel Jewish architects Cremer & Wolffenstein Tadeusz Kościuszko University of Technology alumni Technion – Israel Institute of Technology alumni People from Kraków
```c++ /////////////////////////////////////////////////////////////////////////////// // any_matcher.hpp // // LICENSE_1_0.txt or copy at path_to_url #ifndef your_sha256_hash05 #define your_sha256_hash05 // MS compatible compilers support #pragma once #if defined(_MSC_VER) # pragma once #endif #include <boost/xpressive/detail/detail_fwd.hpp> #include <boost/xpressive/detail/core/quant_style.hpp> #include <boost/xpressive/detail/core/state.hpp> namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // any_matcher // struct any_matcher { BOOST_XPR_QUANT_STYLE(quant_fixed_width, 1, true) template<typename BidiIter, typename Next> static bool match(match_state<BidiIter> &state, Next const &next) { if(state.eos()) { return false; } ++state.cur_; if(next.match(state)) { return true; } --state.cur_; return false; } }; }}} #endif ```
```turing #! /usr/bin/env perl # # in the file LICENSE in the source distribution or at # path_to_url use OpenSSL::Test::Simple; simple_test("test_p5_crpt2", "p5_crpt2_test"); ```
Devora Halter Keidar (8 June 1924 – 17 May 2023) was an Israeli actress. Dvora Kedar was born in Lithuania. She began her acting career in Habima, Israel's National Theatre. In 1964, she appeared in her first movie, Ulai terdu sham. In 1977, she starred in Mivtza Yonatan (Operation Thunderbolt), and 1979 she appeared in Lemon Popsicle as Benji's mother. Nikmato Shel Itzik Finkelstein was her last movie, although she continued to act in Israeli theatre productions. She had two children and four grandchildren. Kedar won the Ophir Award for Best Actress in a Supporting Role. Kedar died on 17 May 2023, at the age of 98. Filmography Fire Birds (2015) - Mrs. Halperin Zaguri (TV Series 2014–2015) - Masuda Ha-Seret Shelanu (2005) - Benzi Mother Itche (TV Series 1994) The Revenge of Itzik Finkelstein (1993) - Mother Summertime Blues (1988) - Benjy's Mother Up Your Anchor (1985) - Sonja Baby Love (1983) - Sonja Private Popsicle (1982) - Sonja Hot Bubblegum (1981) - Sonja, Benjy's Mother Going Steady (1979) - Sonja Lemon Popsicle (1978) - Sonja Operation Thunderbolt (1977) - Freda Ben-David A Gift from Heaven (1973) The Dreamer (1970) - Mother The Prodigal Son (1968) Dreamboat (1963) - Mother One Hundred and One Dalmatians (1961) - Nanny (Israeli version) References External links 1924 births 2023 deaths 20th-century Israeli actresses Ophir Award Winners Israeli film actresses Israeli stage actresses Lithuanian emigrants to Israel Actresses from Vilnius Israeli people of Lithuanian-Jewish descent 21st-century Israeli actresses
Slatnik () is a mountain in northwestern Slovenia. It stands southwest of the Sorica Plateau. Name The name Slatnik appears in Slovenia as both an oronym and a settlement name (e.g., Slatnik, Veliki Slatnik, etc.). Like related names (e.g., Slatenik), it is derived from the common noun slatina 'spring with salty or acidic water', referring to a local geographical feature. References External links Mount Slatnik on Geopedia Mountains of Upper Carniola Municipality of Škofja Loka One-thousanders of Slovenia
Marie Courcelles (fl. 1562 – fl. 1583) was a Scottish court official. She served as lady-in-waiting to Mary, Queen of Scots. Life She arrived to Scotland from France in 1562 to become a lady-in-waiting to queen Mary. She was not the only French lady-in-waiting: nine accompanied the queen from France in 1561 under the supervision of her French chamberlain, Servais de Condé: Guyonne de Péguillon; Marie Pyerres (Madame de Briante), Joanne de la Reyneville (Lady Creich), Isabelle Camp (Demoiselle de Cobron) and Suzanne Constant (Demoiselle de Fonterpuys), as well as seven maids-of-honour under a governess, Madamoiselle de la Souche. In May 1562 the queen bought Courcelles, described as one of her "chamber women" shoes, linen, black taffeta for a skirt, and a farthingale. In January 1563 she was described as a "maiden in the Queen's chamber" and given a black velvet gown with another farthingale. In June 1566 she was "maiden and femme" in the Queen's chamber and was given silk chamlet and velvet for her clothes. When Mary gave linen to her household for Easter in 1567, Courcelle was named in the account among the "femmes de chambre", the chamber women, rather than one of the ladies or maidens. Toussaint Courcelles, a valet in the Queen's chamber, was probably her brother. Claude de Courcelles, a diplomat and secretary of the French ambassador in London Michel de Castelnau, was probably a relation. When the queen was imprisoned at Lochleven, Marie Courcelles was one of the three ladies-in-waiting who accompanied her there (the other two being Mary Seton and Jane Kennedy). Marie Courcelles played a role in the queen's escape. She reportedly took part in planning the escape along with George Douglas and Willie Douglas. On Sunday 2 May 1568, it was she who received the keys from Willie Douglas and brought the queen to the postern gate where a boat was waiting for them with an escort. When the queen escaped from Lochleven Marie Courcelles stayed behind with Mary Seton. She joined Queen Mary in exile at Sheffield Castle. A list of Queen Mary's household made when she was at Coventry in November 1569 notes that Courcelles and Mary Bruce, a daughter of the Laird of Airth, slept in the queen's bedchamber. The queen requested that she might retire and return to France in December 1581. She renewed the request in April 1583. It has been suggested that she accompanied Mary Seton to Reims on her retirement in 1583. See also Mademoiselle Rallay References 16th-century births Scottish ladies-in-waiting Court of Mary, Queen of Scots
Kim Haas is an American journalist. She is the producer and host of the PBS series Afro-Latino Travels with Kim Haas. Biography Haas was born in Philadelphia, Pennsylvania, to Rose and Spencer Lewis. She grew up in the West Mount Airy neighborhood and attended Philadelphia High School for Girls. After graduating in 1986, she attended the University of Pittsburgh, where she majored in Spanish and graduated in 1990. In 1996, Haas earned a master's degree in bilingual and bicultural studies from La Salle University. Haas worked in the media for over 20 years for outlets including Telemundo, where she was marketing director for the Philadelphia station WWSI-TV, and as a pledge host for WYBE-TV. In 2020, Haas created a series on PBS stations called Afro-Latino Travels with Kim Haas, with a grant from the Ford Foundation. Inspired by a visit to Acapulco, Mexico with her grandmother as a child and her time studying abroad in Seville, Spain during college, the show featured Black people's contributions to Spanish-speaking countries, out of her wish to see more Afro-Latino representation on television. While Haas had initially pitched the show around 2009 to public television in Miami, it took several years for her to get funding and for tourism boards to sign on. Another inspiration Haas cited was the travel shows of Anthony Bourdain. The series premiered September 12, 2020. Its first two episodes were set in San José and Limón in Costa Rica and focused on Jamaican immigrants in the country, in particular their role in building its railroad. Haas had planned to shoot future episodes that fall in Salvador, Bahia and Rio de Janeiro in Brazil, but the COVID-19 pandemic stalled those plans. The third episode was shot in Cali, Colombia and is slated to air in 2023. Haas currently lives in Jersey City and runs a communications firm in North Jersey and a blog, Los Afros Latinos, about Afro-Latino culture. References African-American journalists African-American women journalists American television journalists American women television journalists Living people Journalists from Philadelphia People from Jersey City, New Jersey University of Pittsburgh alumni La Salle University alumni Year of birth missing (living people)
```javascript var searchData= [ ['hana',['hana',['../namespaceboost_1_1hana.html',1,'boost']]], ['literals',['literals',['../namespaceboost_1_1hana_1_1literals.html',1,'boost::hana']]] ]; ```
Geisenbrunn is a village in Bavaria, Germany and is located about 22 km southwest of Munich (centre). Since 1978 it is a part of the municipality Gilching which belongs to the district of Starnberg (Landkreis Starnberg). Economy and infrastructure Geisenbrunn is close to the A96 (Bundesautobahn 96) and also a station of the suburban trainsystem of Munich (Munich S-Bahn). Line 8 stops in Geisenbrunn in the direction to “Herrsching” respectively the direction to “airport” (MUC) via Munich city center. Next to some handicraft enterprises, there is the restaurant Gaststätte Geisenbrunn which offers bavarian dishes and the Hotel am Waldhang with bed and breakfast located in Geisenbrunn. Geisenbrunn also has a municipal Kindergarten and its own volunteer fire brigade. Demography The population of Geisenbrunn is about 1,275 people and is increasing rapidly. Culture and sights Geisenbrunn has a vital village life and due to several non-profit associations of Geisenbrunn there are some activities and little festivals throughout the year. The most important activities are: Osterfeuer (in the Easternight) Maifeier (1 May, every three years a new maypole is erected) Dorfkirta (first weekend in July) Löschweiherfest (last Saturday in July) Weinfest (autumn) Glühweinfest (December) Non-profit associations of Geisenbrunn are: Burschenschaft Geisenbrunn e.V. EC Planegg Geisenbrunn e.V. Förderverein Geisenbrunn e.V. Freiwillige Feuerwehr Geisenbrunn e.V. Fußballverein Gilching Geisenbrunn e.V. Hubertus Geisenbrunn-Argelsried e.V. Krokobär e.V. SC Gilching-Geisenbrunn e.V. Stopselverein Geisenbrunn e.V. Volksmusikfreunde Geisenbrunn e.V. Next to the festivals there are some nice spots to enjoy, such as a little well with a bench next to it and a deer enclosure in the center of Geisenbrunn which is liked a lot by smaller children. Geisenbrunn also has a small Chapel “Maria Heimsuchung”. Notes References Villages in Bavaria Starnberg (district)
The Karst Trail () is a marked and signed footpath that runs for over 250 kilometres between Förste in Lower Saxony and Pölsfeld in Saxony-Anhalt through the karst landscape of the South Harz in Germany. The path runs past a number of areas of natural beauty, including caves like the Heimkehle and the Barbarossa Cave, sinkholes like the Juessee and the Schwimmende Insel, depressions, moor landscapes like the Teufelsbäder, karst springs like the Rhumequelle and the Teufelsloch, disappearing streams and subterranean rivers like the Bauerngraben and gypsum rocks. External links Homepage of the Karst Trail Panorama view of the path Osterode map section Nordhausen map section Mansfeld-Südharz map section Kyffhäuser map section Hiking trails in Germany Karst formations of Germany Tourist attractions in Lower Saxony Tourist attractions in Saxony-Anhalt Osterode (district)
```java package com.vladsch.flexmark.ext.gfm.tasklist.internal; ```
Kustaa Jalmari Jyske (9 October 1884 – 19 August 1944; surname until 1906 Friman) was a Finnish politician, born in Rauma. He was a member of the Parliament of Finland from 1919 to 1922, from 1924 to 1927 and from 1930 to 1933, representing the National Progressive Party. He was a presidential elector in the 1931 Finnish presidential election. References 1884 births 1944 deaths People from Rauma, Finland People from Turku and Pori Province (Grand Duchy of Finland) National Progressive Party (Finland) politicians Members of the Parliament of Finland (1919–1922) Members of the Parliament of Finland (1924–1927) Members of the Parliament of Finland (1930–1933)
Cell Project Space is a not-for-profit gallery space and workspace provider based in Cambridge Heath, East London. Cell Project Space presents up to 5 exhibitions and 3-4 events per year and supports the dissemination of artists’ knowledge to the local community through workshops. History Cell Project Space is an independent gallery founded in 1999 by directors Milika Muritu and Richard Priestley that was originally set up as an artist-run exhibition space and is now a registered charity, Cell Foundation. The organisation provides affordable workspace, which in turn supports an on-going programme of exhibitions, projects, talks, screenings, and events. The programme facilitates local and global critical debates while supporting underrepresented artists, collaborating with established and emerging practitioners to present varied formats for exhibition making. Cell extends the gallery's visibility with collective participation through tours and workshops for local secondary schools and the wider community. Cell Project Space and Studios, established in 1999, and charity arm Cell Foundation, founded in 2014, are an affordable artists work space providing leasehold work space to 1097 artists and designer-makers at 7 sites / 147,000 sq ft of B1 work space in east and South East London. As an independent not for profit gallery all funds raised are used solely for the development of artists’ projects and the gallery's public programme. Programme Cell Project Space runs a regular programme of exhibitions, talks & events. Past solo exhibitions include Anna-Sophie Berger, Rosa Aiello & Patricia L. Boyd, Emanuel Almborg, Alan Michael, Dorota Gawęda & Eglė Kulbokaitė, Angharad Williams & Mathis Gasser, Julia Crabtree & William Evans, Mimosa Echard, Jenna Bliss & Gili Tal, Ghislaine Leung, Josh Bitelli, Barbara T. Smith, Yuri Pattison, Rachel Reupke, Peles Empire, Laura Buckley, Anne de Vries, Mark Aerial Waller, Iain Ball, Angelo Plessas, Benedict Drew, Eddie Peake, Jessica Warboys, Celia Hempton, Natalie Dray and Celine Condorelli. The programme has received numerous reviews and press coverage in Art Forum, AQNB, Frieze, Art Monthly, Mousse, The Guardian, Dazed, Studio International and Art Review. Studios Cell Project Space leases 7 commercial buildings across London, which have been converted into affordable artists’ studios. This generates funds that are used to run the programme in the exhibition space located on Cambridge Heath Road. This also allows support for the internship and educational programmes at the gallery. Management structure Board of Trustees Richard Priestley (2014–present) Milika Muritu (2014–present) James Chesterman (2016–present) Femke Oortwijn (2014–16) Directors Milika Muritu, Gallery Programme Curator (1999–present) Richard Priestley, Studios Development (1999–present) Staff Head of Studios Operations: Adam Greenhalgh (2020–present) Studios Administrator Matt Nelmes(2020–present) Associate Curator: Adomas Narkevičius (2021–present) Gallery Manager: Jessie Krish (2021–present) Studio & Gallery Technician: Linas Develis (2015–present) Gallery Assistant: Katrina Nzegwu (2022–present) Associate Curator: Eliel Jones (2020-2021) Gallery Manager & Public Programmes Coordinator: Rachael Davies (2016–2020) Associate Curator: Tim Steer (2016–2019) Studio Operations Manager: Dominic Williams (2014–2020) Studios Management: Huw Chadbourn (2012-2016) Gallery Manager: Femke Oortwijn (2009-2016) References External links Official website Cambridge Heath Contemporary art galleries in London Art galleries established in 2000
Cry for Help or Cry for Help Behind Bars () is a 1928 German silent drama film directed by Franz Hofer and starring Hans Mierendorff, John Mylong, and . Cast References Bibliography External links 1928 films Films of the Weimar Republic German silent feature films Films directed by Franz Hofer German black-and-white films Silent German drama films 1920s German films 1928 drama films
The Tanzlinde, also known as the Tausendjährige Linde or Dorflinde, is a summer lime tree (Tilia platyphyllos) located in Effeltrich, Upper Franconia, on the western edge of Franconian Switzerland. Positioned on the village square across from the fortified church, the lime tress has held a significant role as a central gathering, assembly, and judicial site for centuries. Throughout the 19th and 20th centuries, it also served as a venue for festivals and dances. Notably, the tree's growth features a distinctive flat-oval crown, a result of historical bast extraction for the cultivation of fruit trees. The lime tree in the Franconian region is often seen as the most beautiful among many village lime trees. Many tales, stories, and legends are attributed to the lime tree due to its varied life. Description Despite its old age, the lime tree maintains a strong and vibrant appearance, with its branches retaining well-leafy and abundant blossoms even at the top. The crown rests on a double ring-shaped beam framework comprising 24 supports, with the outer ring sitting on a 49-meter-long and 90-centimeter-high stone wall encircling the tree. This final stone wall also serves to protect the root area inside the wall. Without this framework of beams, the trunk of the Linden tree would break apart under the weight of the strong, spreading branches. Additionally, some of the branches are supported by two iron pipes each. Unlike certain other Tanzlinde trees, such as the one in Sachsenbrunn, the Effeltrich lime tree's branches were never outfitted with a dance platform. The festivities and dances took place beneath the beam structure instead. The crown of the tree boasts a diameter slightly exceeding 20 meters at a height of approximately seven meters. The crown is formed by eight strong, horizontally drawn branches with diameters up to 90 centimeters. The open trunk is closed by several iron bars. The trunk is completely hollow and completely filled with mulm. An adventitious root, about ten centimeters in thickness, has grown within the trunk to enhance nutrient supply to specific portions of the crown. Many of the extended and supported older branches also possess a hollow interior, with some upper sections missing, making the branches essentially half-shells composed of bark material. The appearance of the crown has undergone some changes over the past century. A photograph captured by tree photographer Friedrich Stützer for his tree book "Die größten, ältesten oder sonst merkwürdigen Bäume Bayerns in Wort und Bild" (The largest, oldest or otherwise strange trees of Bavaria in words and pictures) depicts the crown as broader and flatter compared to its present state. In that era, the crown extended several meters beyond the beam framework and the terminating wall, which now roughly defines the crown's boundaries. Since for many years the vertical shoots have no longer been regularly removed for bast extraction, the crown has also partially expanded upwards. The lime tree's wood volume, excluding the root wood, is estimated to be 36 cubic meters. The tree possesses an extensive network of roots. Strong roots were discovered about 40 meters from the trunk in a dung heap and within a cellar. Additionally, while excavating a well, linden roots were unearthed approximately 50 meters away; this discovery may indicate the tree's maximum root reach. Apostle lime tree The lime tree has eight branches spreading from its trunk. Some of these branches extend further, resulting in a total of twelve branches reaching the outer stone wreath. The number twelve stands for the twelve apostles, twelve hours, twelve months, and twelve signs of the zodiac. According to mysticism, it is referred to as an apostle lime tree, of which there are very few in Germany. With the number twelve, there is also a connection to heaven and earth, whereby this can be determined by multiplying three times four. In Greek mythology, the number three signifies the trinity of the gods Zeus, Poseidon, and Hades, although many other gods and mythical figures appear in the trinity. Meanwhile, the number four symbolizes the earth with its four cardinal points north, east, south, and west. Location The lime tree is positioned at the heart of the village square and at the intersection of several roads in the municipality of Effeltrich in the district of Forchheim. To the south, it is 24 kilometers from Nuremberg, and the altitude is about 300 meters above sea level. It is framed by the church castle of St. Georg with high walls and pointed towers and old half-timbered houses and inns. The state road 2243 to Forchheim passes by the Linden tree, which is identical here to the Castle Road. Age Various statements in the literature present differing perspectives on the age of the lime tree. The availability of certain essential components for accurate age determination, such as tree ring counts and radiocarbon dating (14C dating), is limited due to the hollow nature of the trunk and the absence of the oldest wood parts in the inner region. Consequently, the precise age of the Linden tree remains uncertain. Estimates regarding its age span range from 400 to 1000 years. Analysis of the trunk diameter and comparison with similar trees suggests an approximate age of 800 years. The age of the lime tree is often linked to the founding year 1007 of the bishopric of Bamberg, which would imply an age over 1000 years. However, this assertion could be excessive given the presence of deeply shriveled bark on the tree, indicative of high age. Determining age based on trunk circumference is difficult due to the influence of supported main branches, which can lead to a slower growth in thickness. A supported lime tree may be classified as considerably older than a freely grown lime tree with the same trunk diameter and similar environmental conditions. Even prior to World War I, the tree's age was estimated to be at least, 1000 years, as suggested by Gustav von Bezold, the then-director of the (Germanisches Nationalmuseum) Germanic National Museum in Nuremberg. In 1935, experts estimated its age to be around 800 years. The Deutsche Baumarchiv (German Tree Archive), known for its cautious approach to age determinations, offered an estimate of 400 to 670 years in 2007. Nonetheless, the Deutsche Baumarchiv counts the lime tree as among the oldest lime trees in Germany. Hans Joachim Fröhlich, initiator of the Kuratorium Alte liebenswerte Bäume in Deutschland e.V. (Curatorship Old Lovable Trees in Germany e.V.), cited an age range of 800 to 1000 years for the lime tree in 1990. Anette Lenzing's estimation in 2005 also aligns with an age of 800 to 1000 years. In 2007, Michel Brunner's assessment approximated the age of the lime tree to be around 700 years. The lime tree continues to be regarded as one of the oldest trees in Germany. Trunk circumference In 2000, the trunk had a circumference of at least 7.51 meters at the point of smallest diameter. Currently, the circumference at a height of one meter is slightly under eight meters, while at a height of ten centimeters above the ground, it measures over eleven meters. Measurements from 1981 registered a circumference of 8.8 meters at a height of 30 centimeters above the ground, commonly referred to as Brusthöhe (BHU) (breast height). Additionally, measurements conducted in 1987 indicated a circumference of 7.77 meters at a height of one meter above the ground. Fröhlich's data from 1990 recorded a trunk circumference of 8.3 meters at a height of 1.3 meters. History According to tradition, the lime tree was reportedly used as a Thingbaum (Thing tree) by the Wends prior to their Christianization around the year 1004. Historical records suggest that court proceedings may have taken place under the lime tree in earlier centuries. This is suggested by the presence of a stone wreath, approximately 90 centimeters in height, encircling the lime tree. Additionally, the custom of men wearing hats and women wearing white headscarves during festivities under the lime tree aligns with this period, harkening back to the time of the Wends. It is also possible that such celebrations occurred beneath a precursor lime tree that may have occupied the same location. Until the year 1950, the area beneath the lime tree was furnished with tables and benches, offering a place of gathering and providing hospitality through the nearby inn. After the Second World War, the main road that runs adjacent to the lime tree underwent expansion, leading to a gradual rise in motorized vehicle traffic. In 1966, the inattentiveness of two motorists resulted in the unintentional breakage of two substantial branches situated along the road. As a result, the linden tree lost the even, harmonious structure of its crown. The road was slightly moved during a further expansion, giving the lime tree a bit more space. The lime tree is a registered natural monument (ND-04472) and is under protection Fruit tree cultivation The name Effeltrich means place with many apple trees or apple-rich. Even today, the lime tree bears visible signs of its long history of providing bast for fruit tree cultivation: For the grafting of young fruit trees, the young vertical shoots of the lime tree were cut off for decades until about 1850 and their bast was used for tying and fixing the grafts. In order to be able to harvest the branches in sufficient quantity, the emerging branches were bent downwards and fixed in this position. The fixed branches continued to grow in this position. This resulted in the development of strong, cross-branching branches that grew faster and led to the formation of a wide-span crown. From the horizontally fixed branches came vertical shoots, from which more could be harvested as the crown became wider. Lime bast used to be crucial and had various uses, including fruit tree grafting, making knitwear, clothing, shoes, and even war shields. Festival and dance place Throughout its history, the lime tree has served as a focal point for social gatherings. In the 19th century, the tree hosted a variety of festivities and events, including moonshine nights characterized by singing, music, and communal interactions. During the 1850s, "the local dignitaries met once a week during the summer to celebrate the so-called 'Mondscheinnächte' (Moonlight Nights) under the shade of the lime tree with music, singing, and leisurely entertainment.". The tree's appeal extended beyond the local community, attracting individuals from neighboring areas. Among the attendees were academic figures, such as students, professors, and even officers, often hailing from the nearby university town of Erlangen. This tradition of gatherings commenced in the mid-19th century and lasted until 1914. Prince Ludwig, who became King of Bavaria in 1913, visited Effeltrich on June 12, 1912, and a large party was held in his honor under the Linden tree. The children of the village danced in their colorful costumes under the Linden tree. The festivities subsided after the Second World War and the colorful, festive goings-on were gradually forgotten. Redevelopment Despite its hollow interior, the tree has maintained its good condition because it has always been cared for. Because of the increasingly stronger and heavier branches, these were supported from 1905 with a double oak framework by master carpenter Kaul from Poxdorf. This support system is composed of individual supports encircling the tree. Over the years, the tree underwent several rounds of restoration to safeguard its structural integrity. The tree underwent several renovations, such as in 1913 when its trunk, which had developed some hollow areas, was lined with bricks for structural support. However, prior permission had to be obtained from the Bamberg Conservation Committee for this sealing of the trunk. In order to seal the filled-in area, a cement coating was applied. In 1947, the double oak framework from 1905 underwent renewal under the expertise of master builder Hans Batz from Effeltrich. Subsequent restoration efforts took place in 1968, and in 1971 the oak framework was repaired again. In 1977, very extensive renovations were carried out by the "tree doctor" Michael Maurer from Röthenbach an der Pegnitz. In the process, the tree seal, which had been affixed in 1913, was removed from the tree. Recent improvements with regards to the surroundings of the tree outside the crown area were provided with a patchy pavement to ensure adequate water supply to the roots, which extend far from the trunk. Notes See also Linde in Schenklengsfeld References Further reading . . . . . . Friedrich Wallner: Die Dorflinde zu Effeltrich (Oberfranken). In: Friedrich Stützer (Hrsg.): Die größten, ältesten oder sonst merkwürdigen Bäume Bayerns in Wort und Bild. Band 1. Piloty & Löhle, München 1900, pp. 29–31. . . External links Commons: Tanzlinde - Collection of images, videos and audio files The 1000-year-old bast linden tree in Effeltrich - article by Efferer, from June 29, 2008. The millennial linden tree in Effeltrich in Fraenkische Schweiz.Bayern-online.de. Millennial linden tree in Effeltrich - Article by Hans Joachim Fröhlich, excerpt of text from Old lovely trees in Germany, page 287, 29 June 2008. The Tanzlinde zu Effeltrich - Article by Christopher A. Weidner, at Mystische Orten, June 29, 2008. The thousand-year-old linden tree German tree archive Natural monuments in Germany Forchheim (district)
```c++ // Developer- Andrew Kensler (path_to_url // Intro- Generates a mesmerizing 3d image with ray tracing. // Details- path_to_url #include <stdlib.h> #include <stdio.h> #include <math.h> typedef int i;typedef float f;struct v{ f x,y,z;v operator+(v r){return v(x+r.x ,y+r.y,z+r.z);}v operator*(f r){return v(x*r,y*r,z*r);}f operator%(v r){return x*r.x+y*r.y+z*r.z;}v(){}v operator^(v r ){return v(y*r.z-z*r.y,z*r.x-x*r.z,x*r. y-y*r.x);}v(f a,f b,f c){x=a;y=b;z=c;}v operator!(){return*this*(1/sqrt(*this%* this));}};i G[]={247570,280596,280600, 249748,18578,18577,231184,16,16};f R(){ return(f)rand()/RAND_MAX;}i T(v o,v d,f &t,v&n){t=1e9;i m=0;f p=-o.z/d.z;if(.01 <p)t=p,n=v(0,0,1),m=1;for(i k=19;k--;) for(i j=9;j--;)if(G[j]&1<<k){v p=o+v(-k ,0,-j-4);f b=p%d,c=p%p-1,q=b*b-c;if(q>0 ){f s=-b-sqrt(q);if(s<t&&s>.01)t=s,n=!( p+d*t),m=2;}}return m;}v S(v o,v d){f t ;v n;i m=T(o,d,t,n);if(!m)return v(.7, .6,1)*pow(1-d.z,4);v h=o+d*t,l=!(v(9+R( ),9+R(),16)+h*-1),r=d+n*(n%d*-2);f b=l% n;if(b<0||T(h,l,t,n))b=0;f p=pow(l%r*(b >0),99);if(m&1){h=h*.2;return((i)(ceil( h.x)+ceil(h.y))&1?v(3,1,1):v(3,3,3))*(b *.2+.1);}return v(p,p,p)+S(h,r)*.5;}i main(){printf("P6 512 512 255 ");v g=!v (-6,-16,0),a=!(v(0,0,1)^g)*.002,b=!(g^a )*.002,c=(a+b)*-256+g;for(i y=512;y--;) for(i x=512;x--;){v p(13,13,13);for(i r =64;r--;){v t=a*(R()-.5)*99+b*(R()-.5)* 99;p=S(v(17,16,8)+t,!(t*-1+(a*(R()+x)+b *(y+R())+c)*16))*3.5+p;}printf("%c%c%c" ,(i)p.x,(i)p.y,(i)p.z);}} ```
```javascript /** * Calcaultes the fibonacci retracements for given start and end points * * If calculating for up trend start should be low and end should be high and vice versa * * returns an array of retracements level containing [0 , 23.6, 38.2, 50, 61.8, 78.6, 100, 127.2, 161.8, 261.8, 423.6] * * @export * @param {number} start * @param {number} end * @returns {number[]} */ export function fibonacciretracement(start, end) { let levels = [0, 23.6, 38.2, 50, 61.8, 78.6, 100, 127.2, 161.8, 261.8, 423.6]; let retracements; if (start < end) { retracements = levels.map(function (level) { let calculated = end - Math.abs(start - end) * (level) / 100; return calculated > 0 ? calculated : 0; }); } else { retracements = levels.map(function (level) { let calculated = end + Math.abs(start - end) * (level) / 100; return calculated > 0 ? calculated : 0; }); } return retracements; } ```
Harry Anselm Clinch (October 27, 1908 – March 8, 2003) was an American prelate of the Roman Catholic Church. He served as bishop of the Diocese of Monterey in California from 1967 to 1982. He previously served as an auxiliary bishop of the Diocese of Monterey-Fresno from 1956 to 1967. Biography Early life and education Harry Clinch was born on October 27, 1908, in San Anselmo, California, to Henry Joseph and Mary E. (née McLoughlin) Clinch. In 1915, he moved with his family to Fresno, where he attended John Muir Elementary School and Fresno High School (1924–1925). In 1925, Clinch was accepted by Bishop John MacGinley as a seminarian for the Diocese of Monterey-Fresno. He entered St. Benedict's Seminary in Atchison, Kansas, with a grant from the Students Endowment Fund established by the Catholic Church Extension Society. He attended St. Joseph's College in Mountain View from 1928 to 1930, and St. Patrick's Seminary in Menlo Park from 1930 to 1936. Priesthood Clinch was ordained to the priesthood for the Diocese of Monterey-Fresno by Bishop Philip Scher on June 6, 1936. He was diocesan director of the Society for the Propagation of the Faith from 1936 to 1948. In 1937, he founded and became director of Santa Teresita Camp, the diocesan summer camp for children in Three Rivers, California. He also served as diocesan director of the Catholic Youth Organization (1939–1940), a chaplain at St. Agnes Hospital (1942–1946), and dean of Kern and Inyo Counties. From 1941 to 1948, Clinch was editor of the diocesan newspaper, Central California Register. He received his first assignment as a pastor in 1946 at Our Lady of Perpetual Help Parish in Clovis, California, where he remained for two years. In 1948, Clinch became the founding pastor of Sacred Heart Parish in Fresno, California. At Sacred Heart, he constructed a church and established a parochial school. Clinch was appointed pastor of St. Mary's Parish in Taft, California, in 1948. He was elevated by Pope Pius XII to the rank of domestic prelate in October 1952. In 1958, Clinch was assigned to the Carmel Mission Basilica in Carmel-by-the-Sea, California. Auxiliary Bishop of Monterey-Fresno On December 5, 1956, Clinch was appointed as an auxiliary bishop of the Diocese of Monterey-Fresno and titular bishop of Badiae by Pius XII. He received his episcopal consecration on February 27, 1957, from Bishop Aloysius Willinger, with Bishops Timothy Manning and Merlin Guilfoyle serving as co-consecrators. He was the thirteenth native Californian to become a Catholic bishop. As an auxiliary bishop, he continued to serve at the Carmel Mission Basilica. Clinch attended all four sessions of the Second Vatican Council in Rome between 1962 and 1965. Bishop of Fresno Following the split of the Diocese of Monterey from the Diocese of Fresno, Clinch was named bishop of Monterey by Pope Paul VI on October 16, 1967. During his 14-year tenure, Clinch implemented the reforms of the Second Vatican Council, ordained 22 priests, and established five new parishes. In May 1969, he succeeded Cardinal John Wright as episcopal adviser to the National Catholic Laymen's Retreat Conference. Resignation and legacy On January 19, 1982, Pope John Paul II accepted Clinch's resignation as bishop of the Diocese Monterey. He sold his house in Pebble Beach, California, and used the proceeds to establish the Bishop Harry A. Clinch Endowment Fund. Harry Clinch moved to a retirement community in Santa Cruz, California, where he died on March 8, 2003, at age 94. At the time of his death, he was believed to be the last surviving American participant of the Second Vatican Council. See also References 1908 births 2003 deaths People from San Anselmo, California Saint Patrick's Seminary and University alumni People from Carmel-by-the-Sea, California Catholics from California 20th-century Roman Catholic bishops in the United States
The following is a list of county roads in Manatee County, Florida. All county roads are maintained by the county in which they reside. County roads in Manatee County Notes References FDOT GIS data, accessed January 2014 County
Phan Bội Châu (; 26 December 1867 – 29 October 1940), born Phan Văn San, courtesy name Hải Thụ (later changed to Sào Nam), was a pioneer of Vietnamese 20th century nationalism. In 1904, he formed a revolutionary organization called Duy Tân Hội ("Modernization Association"). From 1905 to 1908, he lived in Japan where he wrote political tracts calling for the independence of Vietnam from French colonial rule. After being forced to leave Japan, he moved to China where he was influenced by Sun Yat-sen. He formed a new group called Việt Nam Quang Phục Hội (“Vietnamese Restoration League”), modeled after Sun Yat-sen's republican party. In 1925, French agents seized him in Shanghai. He was convicted of treason and spent the rest of his life under house arrest in Huế. Aliases During his career, Phan used several pen names, including Sào Nam (巢南), Thị Hán (是漢), Độc Tỉnh Tử (獨醒子), Việt Điểu, and Hàn Mãn Tử. Early years Phan was born as Phan Văn San (潘文珊) in the village of Sa Nam, Nam Đàn District of the northern central province of Nghệ An. His father, Phan Văn Phổ, descended from a poor family of scholars, who had always excelled academically. He spent his first three years in Sa Nam, his mother's village, before the family moved to another village, Đan Nhiệm, his father's home village, also in Nam Đàn District. Until Phan was five, his father was typically away from home, teaching in other villages, so his mother raised him and taught him to recite passages from the Classic of Poetry, from which he absorbed Confucian ethics and virtues. When Phan was five, his father returned home and he began attending his father's classes, where he studied the Chinese classics, such as the Three Character Classic, which took him just three days to memorize. As a result of his ability to learn quickly, his father decided to move him to further Confucian texts, such as the Analects, which he practiced on banana leaves. In his autobiography, Phan admitted he did not understand the meaning of the text in great detail at the time, but by age six, he was skillful enough to write a variant of the Analects that parodied his classmates, which earned him a caning from his father. At the time, the central region of Vietnam where his family lived was still under the sovereignty of Emperor Tự Đức, but the southern region had gradually been colonized by Cochinchina campaign in the 1860s. In 1862, Nguyễn dynasty was forced to sign the first Treaty of Saigon that ceded the three east provinces. In 1874, Nguyễn dynasty continued to sign the second Treaty of Saigon that ceded the three west provinces to the French, the whole Nam Kỳ lục-tỉnh (Southern six provinces) became French Cochinchina. In Nghệ-Tĩnh, the Văn Thân movement sprung among the local scholar-gentry with their motto Bình Tây (Pacify the French), and Phan responded at the age of seven by playing Bình Tây game with his classmates, using bamboo guns and lychee bullets. The unrest was enough to prompt the imperial court to bring in troops to quell the opposition to the treaties. Phan's family was not affected by the crackdown, but the movement had a deep impact on him. When Phan was thirteen, his father sent him to another teacher with a better reputation. Since the family lacked the money for Phan to travel far away, he studied with a local cử nhân graduate who was able to borrow a range of books from wealthier families in the area. In 1883, the French finished the colonization of Vietnam by conquering the northern part of Vietnam, and the country was incorporated into French Indochina. Phan drafted an appeal for "pacifying the French and retrieving the North" (bình Tây thu Bắc). He posted the anonymous appeal calling for the formation of local resistance units at intervals along the main road, but there were no responses and the proclamations were soon torn down. Phan realized no one would listen to a person without the social status ensured by passing mandarin examinations. In 1884, his mother died and his aging father was growing weaker, forcing Phan to help support the family. In 1885, the Cần Vương movement began its uprising against French rule, hoping to install the boy Emperor Hàm Nghi as the ruler of an independent Vietnam by expelling colonial forces. The imperial entourage fled the palace in Huế and attempted to start the uprising from a military base in Nghệ An. The scholar gentry of the province rose up, and Phan attempted to rally approximately 60 classmates who were prospective examination candidates to join in the uprising. Phan called his new unit the Sĩ tử Cần Vương Đội (Army of Loyalist Examination Candidates) and convinced an older cử nhân graduate to act as its commander. They had just begun to collect money and raw materials to make ad hoc weapons when a French patrol attacked the village and scattered the students. Phan's father forced him to seek out the commander to have the membership list destroyed to avoid French retributions. With his father growing weaker, Phan decided to keep a low profile to avoid trouble with the French colonials so that he could support his family. He did so by teaching and writing, while still continually preparing for examinations. During this time, he quietly acquired books on military strategy by the likes of Sun Tzu and Đào Duy Từ, the military strategist of the Nguyễn lords who stopped the Trịnh lords with a defensive wall, and Trần Hưng Đạo, the military commander of the Trần dynasty who repelled Mongol invasions of Vietnam in the 13th century. Phan cultivated a small number of his students whom he identified as having abundant pro-independence sentiments. He enthusiastically received visits from Cần Vương visitors and passed on their tales to his students, particularly those concerning Phan Đình Phùng, who led the Cần Vương effort. Phan failed the regional mandarin exams for a number of years in a row. By the time he was 30, he traveled to Huế to teach, to "improve his contacts" and to obtain some special tutoring in preparation for his next exam attempt. In Huế, Phan quickly made friends with similar political values and beliefs. One friend, Nguyễn Thượng Hiền, introduced him to the unpublished writings of , a Vietnamese activist/reformist. This was Phan's first encounter with the Self-Strengthening Movement in China and other major political and military reforms made around the world. After returning to Nghệ An in 1900, Phan passed the regional mandarin exams with the highest possible honors. Marriage and family At the age of 22, Phan married Nguyễn Thị Huy (Thái Thị Huy, ), who was from the same village. The union had long been arranged by their parents, who were acquaintances. Phan was the only son in the family, and his wife initially did not bear him any children, so she arranged for him to be married to a second wife Nguyễn Thị Minh (Phạm Thị Minh) so that the family line could be continued. This practice was not uncommon in Confucian families of the time. His second wife bore him a son (Phan Nghi Đệ) and daughter, and his first wife later bore him another son (Phan Nghi Huynh). When Phan passed the regional examinations in 1900, he was eligible to become a public servant. However, Phan had no intention of pursuing such a career and only wanted the qualification to increase his gravitas in rallying anti-colonial action. With his father dying in the same year, Phan had less family obligations, and decided to travel abroad to pursue his revolutionary activities. Phan met with his wife only once more following the leaving: when he was pardoned and released from Hỏa Lò Prison more than two decades later. He was then sent to a loose form of house arrest in Huế and the train stopped at Vinh, Nghệ An, Vietnam. On the way, his wife said, “I am very happy. From now on, my only wish is that you will hold to your initial aspiration. Do whatever you like, and do not worry about your wife and children.” Activism in Vietnam Phan spent the first five years of the 20th century living in Huế and traveling the country. Phan drew up a three-step plan to get the French out of Vietnam. First, he would need to organize remnants of the Cần Vương movement and other sympathizers of the cause. Second, he would need to attain support from the Vietnamese imperial family and the bureaucracy, many of whom had already come to grips with French colonial rule. Finally, he would need to obtain foreign aid, from Chinese or Japanese revolutionaries, to finance the revolution. It was only later that Phan realized that obtaining independence for Vietnam would be much more difficult than expected. He became familiar with the works of famed European thinkers, such as Voltaire, Rousseau and Darwin. Phan was also influenced by the writings of such Chinese Confucianists as Liang Qichao and Kang Youwei. The European and Chinese works, which had only entered Vietnamese circles a few years later, opened Phan's mind to more expansive thought regarding the struggle for freedom of his people. Liang's Hsin-min ts'ung-pao ("The Renovation of the People") influenced Phan's revolutionary ideas and beliefs, as it criticized the Chinese government and proclaimed that the Chinese people's consciousness needed to be awakened to further the country into the modern era. Kang, one of the major thinkers that influenced Phan, took the idea of Social Darwinism and discussed the survival of the fittest concept as it applied to nations and ethnic groups. He described the dire outcomes that would face China if the country did not embark on a series of reforms, similar to those faced by the Ottoman Empire and colonial India. He believed that reforms made by Peter the Great and Emperor Meiji were excellent examples of the political restructuring that needed to take place to save China. From Kang's work, Phan realized why Emperor Tự Đức's decision to ignore Nguyễn Trường Tộ's proposed modernization reforms had led to the downfall of Vietnam and had allowed for French rule in Vietnam. Phan continued to seek support from the scholar-gentry and the bureaucracy serving the French, before shifting his focus to obtaining support from members of the imperial family. Phan had moved to Huế, claiming that he was preparing for the metropolitan imperial examinations, but in actuality, he planned on drumming up support among the various factions of royal family. Phan traveled to Quảng Nam to meet with Nguyễn Thành, also known by courtesy name Tiểu La, a contemporary anti-colonial revolutionary activist who was involved in the Cần Vương movement. Tiểu La suggested that a royal associate of his, Tôn Thất Toại, could help lead the revolution. Phan rejected the offer, but took Tiểu La's advice to seek support from direct descendants of Emperor Gia Long, the founder of the Nguyễn dynasty. These direct descendants were still highly respected by wealthy Mekong Delta landowners who Phan hoped would raise the bulk of the money needed to finance the revolution. Prince Cường Để and the Vietnam Modernization Association By the spring of 1903, Phan had found a perfect candidate to lead the revolution: Prince Cường Để, a direct descendant of Gia Long's eldest son, Prince Cảnh. Cường Để's descendants had long been dissociated from the emperor and his family since the early 19th century. Cường Để's father was personally sought by Phan Đình Phùng to take Hàm Nghi's place and lead a popular revolt against the French in the 1880s, but he declined. By 1894, he suggested that his son, then 12 years old, could be the new face of the revolution. This plan was never executed as Phan Đình Phùng died in January 1896. Cường Để changed the course of his life and began studying history, economics and geography and thought admiringly of the heroic achievements of Trần Hưng Đạo, Zhuge Liang, Toyotomi Hideyoshi, Saigō Takamori, Cavour, Otto von Bismarck, George Washington, and Abraham Lincoln. After getting Cường Để to support the revolutionary cause, Phan wrote his first significant work, Lưu Cầu Huyết lệ Tân thư (Letter from the Ryukyus written in Tears of Blood). He argued that independence in Vietnam could only be achieved "through a transformation and revitalization of national character". The book was moderately successful amongst the Vietnamese populaces and received attention from other nationalists like Trần Quý Cáp and Phan Châu Trinh. However, many mandarins were reluctant to publicly support Phan's ideas, and as a result, he came to realize that he couldn't rely on the bureaucratic elite to support his cause. Phan created the Việt Nam Duy Tân Hội (Vietnam Modernization Association) in 1904; Cường Để led the association as its president, while Phan served as general secretary. Despite its growing member base, Duy Tân Hội struggled financially. Phan had hoped to obtain financial assistance from China, but the country was forced to abandon its suzerain relationship with Vietnam after the 1884–85 Sino-French War. Phan and Cường Để decided to seek aid from Japan, which had recently won a war against Russia, had successfully imposed reforms and seemed more inclined to help out revolutionaries in a nearby Asian country. Phan was selected to visit Japan to secure the funds needed to sustain Duy Tân Hội. Phan did not speak Japanese and had no contacts in Japan, so he sought help from Liang Qichao, who was living in Japan since being exiled years earlier. Liang introduced Phan to many prominent politicians, including Ōkuma Shigenobu, a well-liked statesman who had previously served as Prime Minister of Japan for a few months in 1898. Phan asked Okuma for financial assistance to fund the activities of Vietnamese revolutionaries. In his letter to Okuma, Phan stated that Japan should be obligated to help Vietnam since both countries were of the "same race, same culture, and same continent". Japan could also promote its interests in Vietnam and prevent French and Russian expansion into China. However, Phan was unsuccessful in procuring aid from the Japanese. The Japanese government did not want to damage its own relationship with France, while opposition party members promised financial aid to Vietnamese students wishing to study in Japan, but also advised Phan not to start a revolutionary movement until Japan was more willing to help the cause. In Guangxi and Guangdong, the Vietnamese revolutionaries arranged alliances with the Kuomintang by marrying Vietnamese women to Chinese officers. Their children were at an advantage since they could speak both languages and they worked as agents for the revolutionaries and spread revolutionary ideologies across borders. This intermarriage between Chinese and Vietnamese was viewed with alarm by the French. Phan's revolutionary network practiced this extensively; additionally, Chinese merchants also married Vietnamese women, and provided funds and help. Early writings Frustrated by the Japanese response, Phan turned to Liang, who explained to Phan it was naïve to expect financial assistance from the Japanese. The Vietnamese people would have to look only within Vietnam for support and financial backing. Liang told Phan that he could best serve the cause by writing and distributing pamphlets advocating for the revolution to rally support from the Vietnamese and others abroad. Phan took Liang's advice very seriously and immediately began to publish materials to obtain support for the revolutionary cause. These writings, perhaps the most widely recognized of Phan's works, include: Việt Nam vong quốc sử (History of the Loss of Vietnam), Tân Việt Nam (The new Vietnam; 1907), Ai Việt điếu Điền (Grief over Vietnam and Condolence for Yunnan; 1907), Hải ngoại Huyết thư (Letter Inscribed in Blood from Abroad; 1907), Việt Nam quốc sử khảo (An Inquiry into the history of Vietnam; 1908). All were initially written in Classical Chinese and then translated to Quốc ngữ, upon which they were smuggled into Vietnam. These works, most notably Việt Nam vong quốc sử, were critical in intensifying the nationalist fervor in the country. Việt Nam vong quốc sử Liang published Phan's 1905 work Việt Nam vong quốc sử (History of the Loss of Vietnam) and intended to distribute it in China and abroad, but also to smuggle it into Vietnam. Phan wanted to rally people to support the cause for Vietnamese independence; the work is regarded as one of the most important books in the history of Vietnam's anticolonialism movement. The book helped revive the name "Vietnam", which was not commonly used at the time. The book is noted for its negative assessment of the response of the Nguyễn dynasty in the 19th century to the colonial challenges facing Vietnam and the failure to modernize, with the Nguyễn instead turning to ultra-orthodox conservative Confucianism. The book presents strident and emotive memorials to the key figures of the Cần Vương movement of the late 1880s and early 1890s, led by mandarins such as Tôn Thất Thuyết and Phan Đình Phùng, who led guerrillas against the French. The Cần Vương attempted to overthrow the French rule and establish the boy emperor Hàm Nghi as the ruler of an independent Vietnam. The book also analyzes the French social and economic policies in Vietnam, which it regards as oppression. In the book, Phan argues for the establishment of a nationwide pro-independence front with seven factions or interested groups with a specific motivation to fight the French colonial authorities. The book is written in a style that differed from the prevailing writing technique and structure of the scholar gentry of the time. The scholar gentry under the Confucian education system fostered by the classical imperial examinations were molded by their study and memorization of classical Chinese poetry and literature. As such, the literary style tended to be poetic, indirect and metaphorical, relying on allusions and imagery to depict an idea. Phan eschewed this traditional style to write in a direct, ordinary prose style, especially in his analytical and argumentative sections. The book precipitated a new style of writing among scholar gentry revolutionaries, who later tended to use a more direct style. The book created a reaction in China, sparking follow-up essays by Chinese writers who were taken aback by the Phan's description of Vietnamese life under French colonial rule. It generated gloomy pieces by Chinese writers who predicted that their nation would suffer a similar fate if they failed to modernize. One such Chinese response later became a teaching text at the Tonkin Free School in Hanoi, a school run by Phan's contemporaries to promote the independence movement. However, Phan did not receive much of a reaction in terms of aid towards his independence efforts, since the book made Chinese readers worry about their own future. The book had a much better reception among Vietnamese readers. Phan and a colleague, , left Japan for the first time in August 1905, carrying 50 copies of the book that were to distributed throughout Vietnam, of which further copies were made inside the country. Phan's direct writing style, without the use of allegories, upset traditionalists but made the book more accessible to literate people who had not been trained in classical literature. Đông-Du Movement In 1905, the Vietnam Modernization Association agreed to send Phan to Japan to get Japanese military assistance or weapons. The Duy Tân Hội had turned more radical after Japan's victory over Russia led to the popular belief that Japan would soon turn its attention to ridding Asia of the western imperialist powers in general. However, Phan soon realized that Japanese military aid would not be possible, and turned his attention to using Japan as a base to train and educate young Vietnamese students, by starting the Đông Du (Visit the East) Society. The number of Vietnamese students sent to Japan for training peaked at 200 in 1908. However, due to pressure from the French government, especially after the signing of the Franco-Japanese Treaty of 1907, Japan declared Phan to be persona non grata and expelled him in 1909. After Đông-Du In 1909, after being deported from Japan, Phan went to Hong Kong with Cường Để. There, he made plans to raise money and bring to Thailand the Vietnamese students who had studied in Japan, but had now been dispersed. He had previously had the foresight to establish a base in Thailand. But instead he received news of an armed uprising in Vietnam, led by Hoàng Hoa Thám (Đề Hoàng Yên-Thế). So he assembled his comrades in Hong Kong, and sent two people to Japan to buy 500 of the Arisaka Type 30 rifles. But after buying the weapons to support the uprising with, they could not afford to hire a ship to smuggle the rifles into Vietnam. So, in July, Phan went to Thailand to ask their government to help with the smuggling. The foreign minister refused, since it would be a major diplomatic incident with France if it leaked out. So he had to return to Hong Kong and wait for the money needed for smuggling. The money never arrived, and news arrived that his fundraising organizer - , also known by courtesy name Ngư Hải - was dead, and that the uprising was going badly. Phan donated 480 of the rifles to the forces of Sun Yat-sen. He then tried to smuggle the remaining 20 of the rifles via Thailand, disguised as first-class luggage. This attempt failed. He spent the first half of 1910 begging on the street, selling his books, and spending all his money getting drunk at the pub. This went on until he met an elderly woman, Chu Bá Linh (Chu sư-thái), who took the entire movement into her house. Funds arrived and he planned to move to Thailand. He arrived in Thailand in November 1910, and all his students and followers who could, took up farming there. Vietnam Restoration League The Wuchang Uprising occurred in China on 10 October 1911. It quickly spread and declared itself the Republic of China. This greatly inspired Phan, since he had many friends among the Chinese revolutionaries. Phan thought this new regime would fix all that was wrong with the old China, and unite with Japan to defeat the Europeans and build a strong Asia. Leaving the farm in the hands of his comrades, he went to China to visit his friends there. The old Vietnam Modernization Association had become worthless, with its members scattered. A new organization needed to be formed, with a new agenda inspired by the Chinese revolution. A large meeting was held in late March 1912. They agreed to form a new group, the Việt Nam Quang Phục Hội (Vietnam Restoration League). Cường Để was made president and chairman; Phan was vice-president. People voted to campaign for democracy instead of a monarchy, despite strong objections of people from southern Vietnam. The organization's sole purpose was to kick out the French and establish a democratic republic. However they had no funds and had great difficulty getting revolutionary leaflets into Vietnam. Also, the new Chinese government was too busy and would not help the movement with anything other than allowing Vietnamese comrades into its education and training system. The Việt Nam Quang Phục Hội came up with a proposed flag design. Previously, Vietnam never had a flag, only banners to represent royalty. Their flag idea had 5 five-pointed stars, arranged in a square with a star in the middle. It symbolized the five regions of Vietnam. The national flag had red stars on a yellow background, and the military flag had a red background with white stars. The yellow represented their race, the red represented fire which represented their location to the south of China (see I Ching), and the white represented the metal of their weapons. They also created a book on military strategy and regulations for their army. They even printed their own currency, which they agreed to honour when, or rather "if", they attained power. If they won they could easily pay people back, and if they lost it wouldn't cost them anything. The "money" was printed in a similar way to the Chinese paper notes. They also formed an organisation called the Chấn-Hoa Hưng-Á Hội (Association for the Revitalization of China). It was dedicated to getting support from China for independence movements in smaller Asian countries, starting with Vietnam of course. Using a medical centre as a front, and a fancy office they managed to create the false impression that they were a huge successful organisation. They got hundreds of people to join, and sold a huge amount of their made-up currency. They changed some of the leadership positions of the Việt-Nam Quang-Phục Hội to allow the Chinese to take part. However, they could not get enough money to buy more weapons until they had proved themselves with a military attack of some sort. Everyone said they needed something big and explosive because the people of Vietnam were short on patience. So Phan sent five people with a few grenades to the three regions of Vietnam. The grenades they sent to the North were used on a minor target, the governor of Thái Bình province, two officers and a French restaurateur. They were meant to be used at the mandarin examinations when all the officials would be gathered. Those they sent to the centre via Thailand did not make it to Vietnam at the time, and they had to throw their grenades away. Those that they sent to the south were used on some Vietnamese. The attacks in the North enraged the French, and they demanded Phan be arrested, but the Chinese government refused. But the value of Phan's special currency dropped dramatically after the failure. They had no money, so they decided to trick a pharmaceutical company in Japan into providing many expensive drugs for them on credit. They then closed down their medical centre and didn't pay their debt. But their membership slowly dwindled, and the difficulty of getting into Vietnam increased. And changes in the government of their Chinese province made things difficult. And they had to close their office and send their comrades away. Vietnam during World War I By 1914, Phan was arrested by the Chinese authorities and thrown in jail on suspicion of helping rival Chinese authorities. The intervention of the Chinese minister for the army stopped them from killing him or handing him over to the French, but he was kept in prison for almost four years, until 1917. In prison he wrote many biographies, including his own, and other books. World War I began shortly thereafter. The country remained a member of the French Empire, and many Vietnamese fought in World War I. Numerous anti-colonial revolts occurred in Vietnam during the war, all easily suppressed by the French. While he was in prison, Phan organised some of his comrades to meet with the German government in Thailand. They donated a large amount of money and promised more if a spectacular action could be done in Vietnam against the French. The comrades attempted an action but failed completely, wasting all the money. After his release, Phan traveled to Beijing and to Japan, and then to various parts of China trying to get back into Vietnam. When he eventually got to the border of Yunnan Province and Vietnam, he discovered that World War I was over and his plans of using it to help defeat the French were hopeless. Phan wandered around China for years after this without accomplishing anything significant. He pondered collaborating with the French, who were now ruled by the Socialist Party (France), and he wrote a booklet about why collaboration with the French would be good. He later changed his mind and blamed this thinking on Phan Bá Ngọc, who was accused by Phan for being a collaborator with the French. Relations with the socialists At the start of 1921, Phan studied socialism and the Soviet Union in the hope of gaining assistance from the Soviet Union or socialist groups. He translated a book called "An Account of the Russian Revolution", by Tatsuji Fuse, into Chinese. He then went to Beijing to meet with Soviet representatives Grigori Voitinsky and Lạp tiên sinh. Lạp said that the Soviet Union would educate, train, and pay for any Vietnamese students Phan wanted to send, provided they would engage in social revolution and teach socialism in Vietnam afterwards. Lạp was keen to hear more about the political situation in Vietnam, since Phan was the first Vietnamese revolutionary to come into contact with them. Lạp requested Phan write a book in English about the situation, but Phan was unable to do so as he spoke no English. Final years In 1925, Phan arrived in Shanghai on what he thought was a short trip on behalf of his movement. He was to meet with Hồ Chí Minh, who at that time used the name Lý Thụy, one of Hồ's many aliases. Hồ had invited Phan to come to Canton to discuss matters of common interest. Hồ was in Canton at the Soviet Embassy, purportedly as a Soviet citizen working as a secretary, translator, and interpreter. In exchange for money, Hồ allegedly informed the French police of Phan's imminent arrival. Phan was arrested by French agents and transported back to Hanoi. This is disputed by Sophie Quinn-Judge and Duncan McCargo, who point out that this is a legend made up by anti-communist authors, considering that Lâm Đức Thụ's reports showed that the French already had all the information they needed from their own spies. Also, according to Quinn-Judge and McCargo, Hồ was rapidly gaining adherence from the "best elements" of Vietnamese Quoc Dan Dang to his ideas, thus having no motivation to eliminate Phan, who considered Hồ more like a successor, rather than a competitor. Thus Hồ had plenty of reasons to support such a respected activist as a figurehead for his movement. When he was transported back to Hanoi, he was held in Hỏa Lò Prison. At first, the French authorities did not release his real name, in order to avoid public disturbances, but it quickly leaked out who he was. A criminal trial followed, with all the charges going back to 1913 when he had been sentenced to death in absentia. The charges included incitement to murder and supplying an offensive weapon used to commit murder in two incidents, which had resulted in the deaths of a Vietnamese governor on 12 April 1913 and of two French majors on 28 April 1913. The court sentenced Phan to penal servitude for life. He was released from prison on 24 December 1925 by Governor General Alexandre Varenne, in response to widespread public protest. On 25 December 1925, Phan left Hanoi to arrive in Huế with Ngô Đức Kế. During this trip, Phan visited Nghệ An, Hà Tĩnh and Quảng Bình to meet his family and supporters. On 16 February 1926, Phan left Quảng Bình and arrived in Huế, since then he become a prisoner in house arrest in Bến Ngự. Phan Bội Châu died on 29 October 1940, about a month after Japan invaded northern Vietnam. Works Việt Nam vong quốc sử (History of the Loss of Vietnam) was written in 1905 while Phan was in Japan. This book was smuggled in Vietnam under the French domination period, and also incorporated into Liang Qichao's Collected Works of Yinbingshi (Chinese: 饮冰室合集). Việt Nam quốc sử khảo (An Inquiry into the history of Vietnam) was written in 1908, first published in 1909 in Japan. Việt Nam quốc sử khảo summarizes 4000-year history of Vietnam from Hùng kings to emperor Tự Đức, focus on the most typical heroes and heroines who fighting against foreign invaders, as well as the biggest territory gains and losses. Việt Nam nghĩa liệt sử (History of the patriots died heroically for the just cause of Vietnam) first published in 1918 in Shanghai, with and Nguyễn Thượng Hiền. This work is a collection of over 50 short stories about members of Cần Vương, Duy Tân and Đông Du movements, who sacrificed their lives for Vietnam's independence from 1906 to 1917, begins with and ends with . Ngục trung thư (Prison Notes) was written in 1913 while Phan was put in jail and facing a death sentence due to a deal between the Liangguang governor and the French Indochina governor. This work was completed just in a few days and has discrepancies with Niên biểu in some important events of the Đông-Du movement. Phan Bội Châu niên biểu (Year to Year Activities) was clandestinely written sometimes during his house arrest in Huế (1925-1940). The basic manuscripts were in Classical Chinese. The first Quốc ngữ edition was published under the title Tự phán (Self Judgment) by Tâm Tâm thư xã, copyright by Phan Nghi Đệ in 1946. The second Quốc ngữ edition was translated by Tôn Quang Phiệt and Phạm Trọng Điềm, published in 1956, reissued in 1957. Legacy and memory After Phan's death, with support from compatriots throughout the country, Huỳnh Thúc Kháng - one of his closest companions - led to build his tomb and temple during late 1940 and early 1941. The Phan Bội Châu memorial site in Huế city including his house, tomb and temple with around 150 artifacts and documents about his life and revolutionary activities became a national relic since 1990. The Phan Bội Châu memorial site in Nam Đàn district became a special national relic since 2016. The relic area consists of two clusters: the cluster of relics in Đan Nhiệm village and the cluster of relics in Sa Nam village.In 1997, an additional gallery was built there with support from Japan. In 2017, the additional gallery was rearranged, complemented and has hundreds of artifacts till now. Most cities in Vietnam have named major streets after Phan Bội Châu. References Citations Sources . . . . . . . . . External links 1867 births 1940 deaths People from Nghệ An province People convicted of treason against France People sentenced to death in absentia Prisoners sentenced to life imprisonment by France Vietnamese expatriates in China Vietnamese expatriates in Japan Vietnamese prisoners sentenced to life imprisonment Việt Nam Quang Phục Hội politicians Vietnamese revolutionaries Vietnamese nationalists Vietnamese independence activists 20th-century Vietnamese philosophers 20th-century Vietnamese calligraphers People of French Indochina
Grace Beatrice Minor (born May 31, 1942) is an Americo-Liberian politician who served as the first female President Pro Tempore of the Senate from 2002 to 2003. She was senator for Montserrado County. Minor was a close ally of president Charles Taylor. Career In 1976, Minor was commissioner of oldest Congotown. In 1980, she was chosen to represent Congotown in the forthcoming elections prior to the coup. Minor was a top aide and close confidante to Taylor when he was head of the General Services Agency, from which he was accused by Samuel Doe of embezzling almost a million US dollars. After he escaped from prison in the United States in 1985, she relocated back to Liberia to support him in founding the National Patriotic Front of Liberia and in financing the civil war. She opened a Swiss bank account for him in 1993. She was regarded as second in Taylor's hierarchy, and as his political and business partner, she was considered the "power behind the throne." Minor was the proponent of the "selective elimination" of the indigenous Liberian leaders in the NPFL, a practice which was so prevalent that in 1992 the Economic Community of West African States accused the NPFL of war crimes. After the founding of the National Patriotic Party and Taylor's success in the 1997 presidential election, Minor was appointed to the Senate, the only female in the government. Following the death of incumbent Keikura B. Kpoto, she was elected President of the Senate in October 2002, the first woman to hold the post. She purchased a house and consultancy firm in Osu, Accra which was managed by her sister. Her son-in-law, Monie Captan, was appointed Foreign Minister. In 2001, she was placed on a United Nations Security Council list of 120 political leaders who were banned from travel outside of Liberia. On August 25, 2004, the United Nations Security Council added Minor's name to its "Assets Freeze List" under Resolution 1521 due to her ongoing ties with Taylor. Minor handled Taylor's investments at least until 2005, while he was in exile, helping him "recruit couriers, coordinate their movements, and handle the money coming and going from Calabar." However, Leymah Gbowee says that Minor "quietly" gave significant amounts from her personal wealth to fund the Women of Liberia Mass Action for Peace. Minor's name was removed from both UN lists on November 28, 2007. In 2009, the Truth and Reconciliation Commission recommended that Minor, along with a number of others, be barred from holding political office in the new republic for thirty years. The ban was overturned in 2011 by the Supreme Court. In 2014, Minor was declared "wanted" by the Civil Law Court of Liberia over the demolition of properties resulting in the displacement of 250 families in Congo Town. It was alleged she sold the land to the National Oil Company, which she denied. References Living people 1942 births Americo-Liberian people National Patriotic Party politicians Politicians from Monrovia Members of the Senate of Liberia Presidents pro tempore of the Senate of Liberia Women in 21st-century warfare 20th-century Liberian women politicians 20th-century Liberian politicians
```javascript PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^!?"(?:[^"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["com",/^;[^\n\r]*/,null,";"]],[["pln",/^[!%@](?:[$\-.A-Z_a-z][\w$\-.]*|\d+)/],["kwd",/^[^\W\d]\w*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[Xx][\dA-Fa-f]+)/],["pun",/^[(-*,:<->[\]{}]|\.\.\.$/]]),["llvm","ll"]); ```
The Brahmaputra Valley semi-evergreen forests is a tropical moist broadleaf forest ecoregion of Northeastern India, southern Bhutan and adjacent Bangladesh. Location and description The ecoregion covers and encompasses the alluvial plain of the upper Brahmaputra River as it moves westward through India's Assam state (with small parts of the ecoregion in the states of Arunachal Pradesh and Nagaland and also south Bhutan and northern Bangladesh). The valley lies between the Himalayas to the north and the Lushai hills to the south and when the river floods during the June to September monsoon it brings up to 300 cm of water onto the plain carrying rich soils to create a fertile environment which has been extensively farmed for thousands of years. Other rivers that water the plains as well as the Brahmaputra include the Manas and the Subansiri. Flora/plants The extensive farming has meant that the original semi-evergreen forest now exists only in patches. Typical canopy trees include the evergreen Syzygium, Cinnamomum and Magnoliaceae along with deciduous Terminalia myriocarpa, Terminalia citrina, Terminalia tomentosa, Tetrameles species. Understory trees and shrubs include the laurels Phoebe, Machilus, and Actinodaphne, Polyalthias, Aphanamixis, and cultivated Mesua ferrea and species of mahogany, cashews, nutmegs and magnolias, with bamboos such as Bambusa arundinaria and Melocanna bambusoides. Fauna/animals Despite the centuries of human clearance and exploitation, the forests and grasslands along the river remain a habitat for a variety of wildlife including tiger (Panthera tigris), clouded leopard (Pardofelis nebulosa), capped langur (Semnopithecus pileatus), gaur (Bos gaurus), barasingha deer (Cervus duvaucelii), sloth bear (Melursus ursinus), wild water buffalo (Bubalus arnee), India's largest population of Asian elephants (Elephas maximus) and the world's largest population of Indian rhinoceros, while Asian black bears live in the higher slopes of the valley sides. Most of these mammals are threatened or endangered species. The Brahmaputra is a natural barrier to the migration of much wildlife and many species, such as the pygmy hog, hispid hare, or the Malayan sun bear, pig-tailed macaque, golden langur, stump-tailed macaque, western hoolock gibbon live on one side of the river only. The area is a meeting point of species of Indian and Malayan origin. The endemic mammals of the valley are the pygmy hog and the hispid hare, both of which inhabit the grasslands of the riverbanks. The valley is home to rich bird life with 370 species of which two are endemic, the Manipur bush quail (Perdicula manipurensis) and the marsh babbler (Pellorneum palustre) and one, the Bengal florican is very rare. Woodland birds like kalij pheasant, great hornbill, rufous necked hornbill, brown hornbill, Oriental pied hornbill, grey hornbill, peacock pheasant and tragopan are quite common. Threats and preservation This area has been densely populated for centuries and most of the valley has been and still are used for agriculture. Some blocks of natural habitat do remain, however, mainly in national parks the largest of which are Manas, Dibru-Saikhowa and Kaziranga National Parks in India. In Bhutan, these areas are part of Royal Manas National Park. Protected areas In 1997, the World Wildlife Fund identified twelve protected areas in the ecoregion, with a combined area of approximately 2,560 km2, that include 5% of the ecoregion's area. Dehing Patkai Landscape, including Dehing Patkai National Park and Dehing Patkai Elephant Reserve Mehao Wildlife Sanctuary, Arunachal Pradesh (190 km2, also includes portions of the Eastern Himalayan broadleaf forests and Himalayan subtropical pine forests) Manas National Park, Assam (560 km2) Bornadi Wildlife Sanctuary, Assam (90 km2) Kaziranga National Park, Assam (320 km2) Orang National Park, Assam (110 km2) Laokhowa Wildlife Sanctuary, Assam (170 km2) Pobitora Wildlife Sanctuary, Assam (80 km2) Sonai Rupai Wildlife Sanctuary, Assam (160 km2) Nameri National Park, Assam (90 km2) Dibru-Saikhowa National Park, Assam (490 km2) D'Ering Memorial Wildlife Sanctuary, Arunachal Pradesh (190 km2) Pabha Wildlife Sanctuary, Assam (110 km2) Vulture breeding Rani Vulture Breeding Centre was established in 2008 inside Brahmaputra Valley semi-evergreen forests at Rani in Kamprup district with the help of Jatayu Conservation Breeding Centre, Pinjore, which now houses 90 vultures as of December 2018. 40 million vultures have died in last 20 years. See also List of ecoregions in Bhutan List of ecoregions in India References External links Geographical ecoregion maps and basic info. Tropical and subtropical moist broadleaf forests Ecoregions of Bhutan Ecoregions of India Biota of Bhutan Biota of India Indomalayan ecoregions Environment of Assam
The Federation Of Kerala Associations In North America (FOKANA) is an umbrella organization formed on July 4, 1983, in New York City to unite all Kerala/Malayali organizations of the American continent. It was during the seventies that many Malayali organizations started to show up all over United States and Canada. Thus, there was a need to unite all these organizations under a single roof. In 1982, under the initiative of Dr. M. Anirudhan, a preliminary meeting was held in Washington D.C., which was chaired by the then Indian Ambassador to United States K.R. Narayanan. This meeting initiated the forming of this organization. Later in 1983, the first Kerala Convention was held in New York city. Personalities like Dr. Syed Muhammaed, the then Indian High Commissioner in London and Mr. Vayalar Ravi, the then-Home Minister of Kerala attended the convention. This convention, through the active efforts of many prominent Keralites, founded the present organization. The 2020-22 President is Georgy Varughese. The international convention will be held in Orlando, Fl on July 07-10, 2022. See also All Malaysia Malayalee Association Confederation of Tamil Nadu Malayalee Associations References Indian-American culture Indo-Canadian culture Malayali organizations Organizations based in North America Kerala 1983 establishments in the United States Diaspora organizations in the United States Kerala diaspora
```objective-c // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. path_to_url #ifndef FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ #define FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ #include <memory> #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" #include "fxbarcode/oned/BC_OnedEANWriter.h" class CBC_OnedEAN13Writer; class CFX_DIBitmap; class CFX_Matrix; class CFX_RenderDevice; class CBC_OnedUPCAWriter final : public CBC_OneDimEANWriter { public: CBC_OnedUPCAWriter(); ~CBC_OnedUPCAWriter() override; // CBC_OneDimEANWriter: uint8_t* EncodeWithHint(const ByteString& contents, BCFORMAT format, int32_t& outWidth, int32_t& outHeight, int32_t hints) override; uint8_t* EncodeImpl(const ByteString& contents, int32_t& outLength) override; bool CheckContentValidity(WideStringView contents) override; WideString FilterContents(WideStringView contents) override; void InitEANWriter() override; int32_t CalcChecksum(const ByteString& contents) override; private: bool ShowChars(WideStringView contents, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple) override; std::unique_ptr<CBC_OnedEAN13Writer> m_subWriter; }; #endif // FXBARCODE_ONED_BC_ONEDUPCAWRITER_H_ ```
```c++ #if !defined(BOOST_PP_IS_ITERATING) // accompanying file LICENSE_1_0.txt or copy at // path_to_url # ifndef INVOKE_DWA20021122_HPP # define INVOKE_DWA20021122_HPP # include <boost/python/detail/prefix.hpp> # include <boost/python/detail/preprocessor.hpp> # include <boost/python/detail/none.hpp> # include <boost/type_traits/is_member_function_pointer.hpp> # include <boost/preprocessor/iterate.hpp> # include <boost/preprocessor/facilities/intercept.hpp> # include <boost/preprocessor/repetition/enum_trailing_params.hpp> # include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> # include <boost/preprocessor/repetition/enum_binary_params.hpp> # include <boost/python/to_python_value.hpp> // This file declares a series of overloaded invoke(...) functions, // used to invoke wrapped C++ function (object)s from Python. Each one // accepts: // // - a tag which identifies the invocation syntax (e.g. member // functions must be invoked with a different syntax from regular // functions) // // - a pointer to a result converter type, used solely as a way of // transmitting the type of the result converter to the function (or // an int, if the return type is void). // // - the "function", which may be a function object, a function or // member function pointer, or a defaulted_virtual_fn. // // - The arg_from_python converters for each of the arguments to be // passed to the function being invoked. namespace boost { namespace python { namespace detail { // This "result converter" is really just used as a dispatch tag to // invoke(...), selecting the appropriate implementation typedef int void_result_to_python; template <bool void_return, bool member> struct invoke_tag_ {}; // A metafunction returning the appropriate tag type for invoking an // object of type F with return type R. template <class R, class F> struct invoke_tag : invoke_tag_< is_same<R,void>::value , is_member_function_pointer<F>::value > { }; # define BOOST_PP_ITERATION_PARAMS_1 \ (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/invoke.hpp>)) # include BOOST_PP_ITERATE() }}} // namespace boost::python::detail # endif // INVOKE_DWA20021122_HPP #else # define N BOOST_PP_ITERATION() template <class RC, class F BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)> inline PyObject* invoke(invoke_tag_<false,false>, RC const& rc, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) { return rc(f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) )); } template <class RC, class F BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)> inline PyObject* invoke(invoke_tag_<true,false>, RC const&, F& f BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) { f( BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT) ); return none(); } template <class RC, class F, class TC BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)> inline PyObject* invoke(invoke_tag_<false,true>, RC const& rc, F& f, TC& tc BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) { return rc( (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT)) ); } template <class RC, class F, class TC BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class AC)> inline PyObject* invoke(invoke_tag_<true,true>, RC const&, F& f, TC& tc BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, AC, & ac) ) { (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT)); return none(); } # undef N #endif // BOOST_PP_IS_ITERATING ```
```c++ /// Source : path_to_url /// Author : liuyubobobo /// Time : 2023-02-11 #include <iostream> #include <vector> using namespace std; /// Brute Force /// Time Complexity: O(nlog(MAX_NUMS)) /// Space Complexity: O(log(MAX_NUMS)) class Solution { public: long long findTheArrayConcVal(vector<int>& nums) { int n = nums.size(); long long res = 0; for(int i = 0, j = n - 1; i <= j; i ++, j --){ if(i == j) res += nums[i]; else{ long long a = nums[i], b = nums[j]; string a_str = to_string(a), b_str = to_string(b); res += atoll((a_str + b_str).c_str()); } } return res; } }; int main() { return 0; } ```
```c++ #include "moving_rms.h" #include "ui_moving_rms.h" MovingRMS::MovingRMS() : ui(new Ui::MovingRMS) , _widget(new QWidget()) , _buffer(1) , _ring_view(_buffer.begin(), _buffer.end()) { ui->setupUi(_widget); connect(ui->spinBoxSamples, qOverload<int>(&QSpinBox::valueChanged), this, [=](int) { emit parametersChanged(); }); } MovingRMS::~MovingRMS() { delete ui; delete _widget; } void MovingRMS::reset() { _buffer.clear(); TransformFunction_SISO::reset(); } QWidget* MovingRMS::optionsWidget() { return _widget; } bool MovingRMS::xmlSaveState(QDomDocument& doc, QDomElement& parent_element) const { QDomElement widget_el = doc.createElement("options"); widget_el.setAttribute("value", ui->spinBoxSamples->value()); parent_element.appendChild(widget_el); return true; } bool MovingRMS::xmlLoadState(const QDomElement& parent_element) { QDomElement widget_el = parent_element.firstChildElement("options"); if (widget_el.isNull()) { return false; } ui->spinBoxSamples->setValue(widget_el.attribute("value").toInt()); return true; } std::optional<PJ::PlotData::Point> MovingRMS::calculateNextPoint(size_t index) { size_t buffer_size = std::min(size_t(ui->spinBoxSamples->value()), size_t(dataSource()->size())); if (buffer_size != _buffer.size()) { _buffer.resize(buffer_size); _ring_view = nonstd::ring_span<PJ::PlotData::Point>(_buffer.begin(), _buffer.end()); } const auto& p = dataSource()->at(index); _ring_view.push_back(p); while (_ring_view.size() < buffer_size) { _ring_view.push_back(p); } double total_sqr = 0; for (size_t i = 0; i < buffer_size; i++) { double val = _ring_view[i].y; total_sqr += val * val; } double time = p.x; PJ::PlotData::Point out = { time, sqrt(total_sqr / _ring_view.size()) }; return out; } ```
```python #!/usr/bin/env python3 # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the copyright holder nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # import ipaddress import unittest import config import command import thread_cert # Test description: # # This test verifies the radio filter mechanism. # # Topology: # # Leader -- Router # | # | # Child # # LEADER = 1 ROUTER = 2 SED = 3 WAIT_TIME = 5 class RadioFilter(thread_cert.TestCase): USE_MESSAGE_FACTORY = False SUPPORT_NCP = False TOPOLOGY = { LEADER: { 'mode': 'rdn', 'allowlist': [ROUTER, SED] }, ROUTER: { 'mode': 'rdn', 'allowlist': [LEADER] }, SED: { 'is_mtd': True, 'mode': '-', 'timeout': config.DEFAULT_CHILD_TIMEOUT, 'allowlist': [LEADER] }, } def test(self): leader = self.nodes[LEADER] router = self.nodes[ROUTER] sed = self.nodes[SED] nodes = [leader, router, sed] leader.start() self.simulator.go(config.LEADER_STARTUP_DELAY) self.assertEqual(leader.get_state(), 'leader') router.start() self.simulator.go(WAIT_TIME) self.assertEqual(router.get_state(), 'router') sed.start() sed.set_pollperiod(40) self.simulator.go(WAIT_TIME) self.assertEqual(sed.get_state(), 'child') # Validate initial state of `radiofilter` upon start for node in nodes: self.assertFalse(node.radiofilter_is_enabled()) leader_mleid = leader.get_mleid() router_mleid = router.get_mleid() sed_mleid = sed.get_mleid() # Validate connections by pinging from leader, SED, and router self.assertTrue(leader.ping(router_mleid)) self.assertTrue(sed.ping(leader_mleid)) self.assertTrue(router.ping(leader_mleid)) # Validate behavior when `radiofilter` is enabled on router router.radiofilter_enable() self.assertTrue(router.radiofilter_is_enabled()) self.assertFalse(leader.ping(router_mleid)) self.assertFalse(router.ping(leader_mleid)) # Validate behavior when `radiofilter` is disabled on router router.radiofilter_disable() self.assertFalse(router.radiofilter_is_enabled()) self.assertTrue(leader.ping(router_mleid)) self.assertTrue(router.ping(leader_mleid)) # Validate `radiofilter` behavior on sed. self.assertTrue(sed.ping(leader_mleid)) sed.radiofilter_enable() self.assertTrue(sed.radiofilter_is_enabled()) self.assertFalse(sed.ping(leader_mleid)) self.assertTrue(sed.radiofilter_is_enabled()) self.assertEqual(sed.get_state(), 'detached') sed.radiofilter_disable() self.assertFalse(sed.radiofilter_is_enabled()) self.simulator.go(WAIT_TIME) self.assertEqual(sed.get_state(), 'child') self.assertTrue(leader.ping(sed_mleid)) self.assertTrue(sed.ping(leader_mleid)) # Validate energy scan when `radiofilter` is enabled scan_result = leader.scan_energy() self.assertTrue(len(scan_result) > 0) leader.radiofilter_enable() self.assertTrue(leader.radiofilter_is_enabled()) scan_result = leader.scan_energy() self.assertTrue(len(scan_result) == 0) if __name__ == '__main__': unittest.main() ```
The Players Tour Championship was a series of snooker tournaments comprising some minor-ranking events played in Europe, and an Asian leg comprising some minor-ranking events in Asia. The series concluded with a Grand Final, where qualification was based on performance in the other PTC events, and had the status of a full ranking tournament. Each regular event lasted for at least three days, with qualifying days for amateurs should the event be oversubscribed. Each event costs £100 to enter, and Main Tour players can gain ranking points in the events. History The inaugural series ran from late June, with six events at the World Snooker Academy in Sheffield, one in Gloucester and another five in mainland Europe (with 3 in Germany). The finals took place in March featuring the best 24 players who had won the most money and played at least 6 events; 3 in Sheffield and 3 in mainland Europe. The prize money at each event was £50,000 or €50,000 at the regular events, with a total of £200,000 available in the Finals. The first event was held in the World Snooker Academy from 25 to 27 June 2010. In the first season the six events at the Academy were sponsored by Star Xing Pai. The prize money for the Finals was increased to £250,000 in 2011/2012. Originally the events played outside Sheffield were called Euro Players Tour Championship, but this distinction was abandoned for the second season. In the 2012/2013 season the Players Tour Championship was expanded. The PTCs would no longer take place at the World Snooker Academy and instead were played at the South West Snooker Academy. In addition there was a decrease of PTCs being played in England, reduced to four events, with three new PTCs being created in Asia, called Asian Players Tour Championship. From this season the European events formed the European Tour, their prize money was increased to €70,000, and they were sponsored by Betfair. Finally as a result the Finals was expanded to accommodate 32 players instead of 24; with each tournament winner from the APTCs and the next top 4 players on the Asian Order of Merit qualifying; with an additional player qualifying from the UK/European Order of Merit. The seedings of the final were based on the combined list of both Order of Merits. The prize money of the Finals was also increased to £300,000, excluding the £1,000 prize money for Ding Junhui's maximum break. In the 2013/2014 season the number of minor-ranking PTC events was reduced to twelve. The number of events played in England was further decreased to two, and the number of Asian events was raised to four. From this season the events held in Asia formed the Asian Tour, and the English events became part of the European Tour. The prize money of the continental European Tour events was increased to €125,000. The Finals still accommodated 32 players, but the number of qualified players from the Order of Merits has also changed with 24 coming through the European Tour Order of Merit and eight through the Asian Tour Order of Merit. The calculation method of the European Tour Order of Merit was also changed this season. The previously used €1=£1 system was changed to accommodate the increasing prize money of the continental European events. World Snooker decided to use the €1.2=£1 conversion rate. In the 2014/2015 season the number of minor-ranking PTC events was further reduced to only nine events. There are no events played in England, and the number of Asian events was reduced to three after the second event, originally planned to be held in August, had to be cancelled. The prize money of the Grand Final was increased to £350,000. Reaction: criticism and support The PTC has been both criticised and supported by players. The PTC was criticised by several players for its comparatively low prize fund and associated costs. The events offered a top prize of just £10,000 while the first professional round offered no prize money at all. Ronnie O'Sullivan believed that the top players were not rewarded appropriately for what they do, while the lower-ranked players were left with financial losses, and stated that he felt "blackmailed" into entering the events due to the governing body's decision to attach ranking points to them. O'Sullivan likened the experience of competing on the PTC to being "raped". Stephen Maguire echoed O'Sullivan's sentiments, commenting that players were left out of pocket unless they did "really well", and that he felt like a "prostitute" being "forced" to play in the events. Maguire further criticised the lack of atmosphere and audience at some of the events. Another player described the European PTC events as "buying ranking points". Steve Davis, on the other hand, believed that the events have been well received by most of the players and fans, and that they are integral to reinvigorating the circuit. Neil Robertson concurred with Davis' view and considered them important in developing the game overseas, and expressed his hopes that they would develop into fully sponsored and televised tournaments. Stephen Hendry welcomed the increase in playing opportunities for the players, but sympathised with O'Sullivan's view about being 'blackmailed' into entering the events, stating that he believed the events were too "top heavy" on ranking points considering "how little money there is to win". The World Snooker Association stated that they had an obligation to provide playing opportunities for all players on the tour, and that while the top prize for the PTC events was relatively low, 24 players qualify for the Grand Final, which offered a top prize of £70,000 in 2011/2012. It affirmed its stance by stating "Two seasons ago there were only seven or eight events on the main tour calendar; now there are nearly 30 and total prize money has virtually doubled." Series finals and Order of Merit winners Statistics Players Tour Championship – (Minor-ranking events) Event champions by country References Recurring sporting events established in 2010 2010 establishments in England Recurring sporting events disestablished in 2016 2016 disestablishments in England Defunct snooker competitions Snooker tours and series
```elixir defmodule Nerves.Artifact.Resolvers.GiteaAPI do @moduledoc false @behaviour Nerves.Artifact.Resolver alias Nerves.Utils.{HTTPClient, Shell} defstruct artifact_name: nil, base_url: nil, headers: [], http_client: HTTPClient, http_pid: nil, public?: false, opts: [], repo: nil, tag: "", token: "", url: nil @impl Nerves.Artifact.Resolver def get({repo, opts}) do opts = %{struct(__MODULE__, opts) | opts: opts, repo: repo} |> maybe_adjust_token() |> add_http_opts() |> maybe_start_http() result = fetch_artifact(opts) opts.http_client.stop(opts.http_pid) result end defp add_http_opts(opts) do headers = if opts.public? do [] else # make safe values here in case nil was supplied as an option # The request will fail and error will be reported later on token = opts.token || "" [{"Authorization", "token " <> token}] end %{ opts | headers: headers, url: Path.join([opts.base_url, "api", "v1", "repos", opts.repo, "releases", "tags", opts.tag]) } end defp maybe_adjust_token(opts) do token = System.get_env("GITEA_TOKEN") if token do # Let the env var take precedence %{opts | token: token} else opts end end defp maybe_start_http(%{http_pid: pid} = opts) when is_pid(pid), do: opts defp maybe_start_http(opts) do {:ok, http_pid} = opts.http_client.start_link() %{opts | http_pid: http_pid} end defp fetch_artifact(opts) do info = if System.get_env("NERVES_DEBUG") == "1", do: opts.url, else: opts.artifact_name Shell.info([" [Gitea] ", info]) with {:ok, assets_or_url} <- release_details(opts), {:ok, asset_url} <- get_asset_url(assets_or_url, opts) do opts.http_client.get(opts.http_pid, asset_url, headers: [{"Accept", "application/octet-stream"} | opts.headers] ) end end defp release_details(opts) do case opts.http_client.get(opts.http_pid, opts.url, headers: opts.headers, progress?: false) do {:ok, data} -> Jason.decode(data) {:error, "Status 404 Not Found"} -> invalid_token? = is_nil(opts.token) or opts.token == "" msg = if not opts.public? and invalid_token? do """ Missing token For private releases, you must authenticate the request to fetch release assets. You can do this in a few ways: * export or set GITEA_TOKEN=<your-token> * set `token: <get-token-function>` for this Gitea repository in your Nerves system mix.exs """ else "No release" end {:error, msg} result -> result end end defp get_asset_url(url, _) when is_binary(url), do: {:ok, url} defp get_asset_url(%{"assets" => []}, _opts) do {:error, "No release artifacts"} end defp get_asset_url(%{"assets" => assets}, %{artifact_name: artifact_name}) do ret = Enum.find(assets, fn %{"name" => name} -> String.equivalent?(artifact_name, name) end) case ret do nil -> available = for %{"name" => name} <- assets, do: [" * ", name, "\n"] msg = ["No artifact with valid checksum\n\n Found:\n", available] {:error, msg} %{"browser_download_url" => url} -> {:ok, url} end end end ```
Cubanea is a village and municipality in Río Negro Province in Argentina. References Populated places in Río Negro Province
Sidney Katherine Powell (born May 1, 1955) is an American attorney, former federal prosecutor, and conspiracy theorist who attempted to overturn the 2020 United States presidential election. In August 2023, she was indicted along with Donald Trump and eighteen others in the prosecution related to the 2020 election in Georgia, arising from the attempt by the former president and his allies to subvert the election outcome in Georgia and other key states lost by Trump. In October 2023, as part of an agreement with Georgia prosecutors, she pleaded guilty to six misdemeanor counts of conspiring to intentionally interfere with the performance of election duties. She was sentenced to six years of probation and agreed to testify against the other defendants. Powell began her career as an assistant United States attorney in the Western District of Texas. During her tenure, she prosecuted Jimmy Chagra, who was implicated in the May 1979 assassination of United States district judge John H. Wood Jr. In 2003 she represented James Brown, a Merrill Lynch executive involved in the Enron scandal; a decade later she wrote Licensed to Lie: Exposing Corruption in the Department of Justice to denounce the judicial corruption she perceived in Brown's trial. In 2019, Powell defended retired lieutenant general Michael Flynn in United States v. Flynn. She claimed that Flynn was framed by a covert "deep state" operation, and has promoted personalities and slogans associated with the QAnon conspiracy theory. In 2020, Powell joined the legal team of then-President Trump in an attempt to overturn Joe Biden's victory in the 2020 presidential election. She alleged that a secret international cabal involving communists, "globalists", George Soros, Hugo Chávez (who died in 2013), the Clinton Foundation, the CIA, and thousands of Democratic and Republican officials—including then-Trump ally and Georgia governor Brian Kemp—used voting machines to transfer millions of votes away from Trump in the 2020 presidential election. Powell continued filing election lawsuits independently in district courts, and ultimately lost four federal lawsuits in Michigan, Georgia, Arizona, and Wisconsin. After several interviews in which Powell spread election fraud lies, Trump's legal team distanced itself from her, though she continued to meet with the president in the White House. After she accused the election technology companies Dominion Voting Systems and Smartmatic of engaging in a conspiracy to rig the election, both companies sued her for defamation. In August 2021, Michigan federal judge Linda Vivienne Parker formally sanctioned Texas conspiracy theorist L. Lin Wood, Powell, and seven other pro-Trump lawyers for their suit seeking to overturn Trump's election loss. She determined the nine attorneys had participated in "a historic and profound abuse of the judicial process ... by filing baseless and frivolous lawsuits in order to undermine public confidence in the democratic process". The judge ordered them to pay the state of Michigan and the City of Detroit for their expenses in defending against the lawsuit. The court also referred Powell and the other lawyers to state disciplinary authorities for possible disbarment for ethics violations. The State Bar of Texas' Texas Commission for Lawyer Discipline brought a disciplinary action against Powell, alleging that she violated the rules of professional conduct governing lawyers; that proceeding is pending. Early life and education Sidney Katherine Powell was born in Durham, North Carolina, grew up in the city of Raleigh, and knew from an early age that she wanted to be a lawyer. She graduated from Needham Broughton High School and attended the University of North Carolina at Chapel Hill, where she earned a Bachelor of Arts. At the age of 19, she was accepted into the University of North Carolina School of Law, where she graduated in 1978 with a Juris Doctor degree. She began her legal career as one of the youngest federal prosecutors in the U.S. Career From 1978 through 1988, Powell was an assistant United States attorney for the Western and Northern Districts of Texas and the Eastern District of Virginia, where she handled civil and criminal trial work. She was appointed Appellate Section Chief for the Western District of Texas and then the Northern District of Texas. Powell established her own law firm in 1993 in Dallas, Texas. Around 2002, she began to practice in Asheville, North Carolina, but moved back to Texas later. Prosecution for assassination of Judge John H. Wood Powell was one of the prosecutors in the 1979 trial of Jimmy Chagra who was accused in the assassination of John H. Wood Jr., a federal judge from Texas. He was acquitted of involvement in the assassination but convicted on other charges. He later admitted to his role in the conspiracy to murder the judge. Advocacy for Enron In the 2000s Powell represented firms and executives involved in the Enron scandal, including the accounting firm Arthur Andersen and former Merrill Lynch executive Jim Brown. She was an outspoken critic of the Enron Task Force prosecutions, and accused prosecutor Andrew Weissmann of overreach. After that, Powell wrote extensively about prosecutorial abuses in the 2014 book Licensed to Lie. The book was noticed by then-Senator Orrin Hatch, who described it as "powerful". Post-conviction defense of Ted Stevens In Licensed to Lie, Powell contended that prosecutors in the corruption trial of U.S. senator Ted Stevens of Alaska, held in 2008, before federal judge Emmet G. Sullivan in the United States District Court for the District of Columbia, intentionally withheld "Brady material" they should have disclosed to the defense and that they returned Rocky Williams, a terminally ill witness, to Alaska, ostensibly so that his testimony would not exonerate Stevens. The senator was subsequently convicted of seven felony counts of corruption for failing to annually declare gifts from VECO owner Bill Allen. However, due to numerous instances of prosecutorial misconduct, Attorney General Eric Holder moved to dismiss the indictment prior to sentencing, effectively vacating the conviction. Post-conviction defense of Michael Flynn After publishing her first book, Powell continued writing opinion pieces for right-leaning websites. In 2017, Weissmann joined Robert Mueller's Special Counsel investigation, reviving interest in Licensed to Lie from Newt Gingrich and Sean Hannity. Using her status as a former federal prosecutor, Powell became a leading voice against the Mueller investigation; in a February 2018 op-ed, Powell wrote that retired lieutenant general Michael Flynn should "withdraw his guilty plea" for making false statements to the FBI, alleging "egregious government misconduct". Powell's appearances on Fox News to discuss the Flynn case were noticed by President Donald Trump, and the two spoke on several occasions. To raise money for Flynn's defense, Powell spoke at a November 2018 conference, where she met Flynn's siblings. They agreed that Flynn was the victim of a "deep state plot" and had only pleaded guilty because he was coerced. Flynn released his law firm of Covington & Burling and retained Powell to serve as his lead attorney in June 2019. On the same day this was disclosed, Powell sent a letter to Attorney General William Barr requesting the "utmost confidentiality" and argued that Flynn's prosecution was due to "corruption of our beloved government institutions for what appears to be political purposes". Among other things, she requested that Barr appoint an outsider to investigate. Six months later, Barr appointed Jeffrey Jensen to conduct an investigation. The Justice Department filed a motion to drop Flynn's prosecution with presiding federal judge Emmet G. Sullivan in May 2020. Sullivan did not immediately grant the motion; Powell later requested a writ of mandamus from the United States Court of Appeals for the District of Columbia Circuit to compel Sullivan to drop the case. After an initial ruling in favor of Powell by a three-judge panel of the court, the case was appealed to the full court, which denied the mandamus request in an 8–2 ruling and returned the case to Sullivan's court. Powell had argued to the full court that Sullivan's role was "ministerial", giving him no discretion but to comply with the Justice Department motion, to which judge Thomas Griffith replied: "It's not ministerial and you know it's not. So it's not ministerial, so that means that the judge has to do some thinking about it, right?" Other judges on the court also pushed back on Powell's characterization of a federal judge's role. After Trump pardoned Flynn in November 2020, Sullivan dismissed the case as moot, though he stated he probably would have denied the Justice Department motion had the case proceeded. According to a Justice Department official, the Justice Department was not consulted about the pardon. Soon after taking the Flynn case, Powell had accused the Justice Department of prosecutorial misconduct against Flynn; in a footnote to a June 2020 court brief, the department described Powell's allegations as "unfounded and provide no basis for impugning the prosecutors from the D.C. United States Attorney's Office". Powell has been described as a proponent of conspiracy theories about Flynn, namely that he was framed by members of the "deep state" who were trying to eject President Donald Trump from office. 2020 presidential election Days before the 2020 presidential election, Dennis Montgomery, a software designer with a history of making dubious claims, asserted that a government supercomputer program would be used to switch votes from Trump to Biden on voting machines. Powell promoted the conspiracy theory on Lou Dobbs Tonight on November 6, and again on November 8, 2020, on Maria Bartiromo's Fox Business program, ...claiming to have "evidence that that is exactly what happened". On December 10, – long after other hosts had started to push her for more evidence – Dobbs continued to praise her. "Sidney Powell, thank you for all you're doing," "It is the Lord's work." The Washington Post indicated Bartiromo asked Powell for proof of specifics of voting fraud made by her, supposedly including dead voters casting ballots, ballots lacking Trump's name, and a postal employee's confession that he had postdated mailed ballots. She said "Sidney, we talked about the Dominion software." "I know that there were voting irregularities. Tell me about that." Powell also asserted that the CIA ignored warnings about the software, and urged Trump to fire director Gina Haspel. Christopher Krebs, director of the Cybersecurity and Infrastructure Security Agency (CISA), characterized the supercomputer claim as "nonsense" and a "hoax". CISA described the 2020 election as "the most secure in American history", with "no evidence that any voting system deleted or lost votes, changed votes or was in any way compromised". In the wake of the election, Trump established a legal team to challenge the legitimacy of the results. On November 14, Trump named Rudy Giuliani to lead the team, with Victoria Toensing, her husband Joseph diGenova, Jenna Ellis, and Powell as members of this team. The team proceeded to file numerous lawsuits in several states over alleged vote harvesting, illegal votes, machine errors, vote dumps, and late-counted votes. Precisely how Powell gained prominence in the legal team is unknown, even to some campaign officials. One official claimed Powell "simply showed up at headquarters". Giuliani and Powell alleged multiple instances of voter fraud in key states at a November 19 press conference. They cited an affidavit—filed by Russell Ramsland and L. Lin Wood on behalf of the Trump campaign—as evidence of manipulated results. In their comparison of votes cast against total voters registered in Michigan, Powell asserted that they found over-voting of "up to 350 percent in some places". However, the affidavit's conclusion was erroneous since it compared the Michigan vote tallies against population data from Minnesota (whose respective abbreviations are MI and MN, a possible source of the error). When The Washington Post independently checked the numbers, no voter discrepancies were found. When questioned the next day, Wood described this as "a simple mistake" and said the affidavit "will be corrected if it hasn't been already". After Giuliani's segment ended, Powell took the lectern and alleged, without evidence, that an international communist plot to rig the 2020 election had been engineered by Cuba, China, Venezuela, Hugo Chávez (who died in 2013), George Soros, the Clinton Foundation and antifa. She also alleged that Dominion Voting Systems "can set and run an algorithm that probably ran all over the country to take a certain percentage of votes from President Trump and flip them to President Biden". The source for many of these claims appeared to be far right news organization One America News Network (OANN). She also repeated a conspiracy theory—spread by Congressman Louie Gohmert, OANN and others—that election results showing a landslide victory for Trump had been transmitted to the German office of the Spanish electronic voting firm Scytl, after which a company server was supposedly seized in a raid by the United States Army. The US Army and Scytl refuted these claims; Scytl has not had any offices in Germany since September 2019 and does not tabulate US votes. In a March 2021 report, the Justice and Homeland Security Departments flatly rejected accusations of voting fraud conducted by foreign nations. Jonathan Karl, former ABC News chief White House correspondent for the duration of the Trump presidency, wrote in his November 2021 book, Betrayal, that Powell told Defense Department official Ezra Cohen-Watnick that CIA director Gina Haspel had been injured and detained in Germany while attempting to retrieve the alleged server and destroy the purported evidence. She asked Cohen-Watnick, who previously worked under Flynn in the government, to launch a special operations mission to physically seize Haspel and compel her to confess. Later on the evening of November 14, on his Fox News program Tucker Carlson Tonight, conservative commentator Carlson said he had invited Powell onto his show to provide proof of her allegations. After repeated requests, he said Powell became angry with him and said he should "stop contacting her." Carlson's team contacted other figures in the Trump campaign who said that Powell had not given them evidence of her allegations. In an interview with Newsmax on November 21, Powell accused Georgia's Republican governor, Brian Kemp, of being "in on the Dominion scam" and suggested financial impropriety. Powell additionally alleged that fraud had cost Doug Collins the nonpartisan blanket primary against incumbent Kelly Loeffler in the Senate race in Georgia. She also claimed the Democratic Party had used rigged Dominion machines to defeat Bernie Sanders in the 2016 primary, and that Sanders learned of this but "sold out". She said she would "blow up" Georgia with a "biblical" court filing. Powell suggested that candidates "paid to have the system rigged to work for them". On the basis of these claims, Powell called for Republican-controlled state legislatures in swing states to disregard the election results and appoint a slate of "loyal" electors who would vote to re-elect Trump, based on authority supposedly resting in Article Two of the Constitution. Giuliani and Ellis issued a November 22 statement that Powell was "practicing law on her own" and was not (or was no longer) a part of the Trump legal team. According to The Washington Post, the Trump campaign cut ties with Powell because she was seen as harming Trump's broader legal efforts, and because Trump disliked the coverage she received from Tucker Carlson Tonight. Shortly after the announcement, her client Michael Flynn tweeted that Twitter had suspended her account for twelve hours, and that she agreed with the campaign's announcement and was "staying the course" to prove election fraud. On November 23, Fox executive Raj Shah informed his superiors that Fox staff had entreated numerous of its sources within Trump's administration "...to inform reporters that Powell offered no evidence for her claims and didn’t speak for the president." Despite this, on November 24 she joined host Lou Dobbs to tell his viewers that in Arizona, "...there were 35,000 votes added to every Democrat candidate just to start their voting off. It's like getting your $500 of Monopoly money to begin with when you haven’t done anything, and it was only for Democrats." Dominion Voting Systems released a statement refuting Powell's fraud claims on November 26. A draft executive order dated December 16 called for Trump to order a military seizure of voting machines and the appointment of a special counsel; when it surfaced a year later, it was not immediately clear who drafted it. Trump ally Bernard Kerik testified to the January 6 committee that Michael Flynn associate Phil Waldron originated the idea of a military seizure of voting machines. Powell, who had previously called on the president to invoke the Insurrection Act to deploy military forces, joined an Oval Office meeting on December 18, with Giuliani, Flynn, and Pat Cipollone. There, Trump suggested naming Powell as a special counsel to investigate allegations of election fraud. Most Trump advisors opposed the idea, while Powell characterized them as quitters. The meeting was reportedly heated and included Flynn's proposal for the president to declare martial law. By December 2020 over 4,000 attorneys had signed an open letter asking bar disciplinary authorities to condemn and investigate Powell's behavior. In May 2021, Powell continued to express the hope that the election result would be reversed. She spoke at a QAnon conference in Dallas over Memorial Day weekend, where she falsely asserted Trump "can simply be reinstated, that a new Inauguration Day is set", eliciting cheers from the crowd. The date for this was supposedly August 13, however this date passed and Trump was not reinstated. Powell was subpoenaed in January 2022 to testify before the House Select Committee on the January 6 Attack. She sued to block release of her phone records. Independent election lawsuits While working for Trump, Powell stated she would "release the Kraken", a catchphrase from the 1981 film Clash of the Titans, and the expression spread across Twitter. After the Trump campaign cut ties with Powell, she continued to file independent election lawsuits in Arizona, Georgia, Michigan, and Wisconsin. Sources described Powell's election-related filings as filled with significant "sloppy mistakes". In her Georgia lawsuit, she claimed that a computer algorithm took votes from Biden and flipped them to Trump, later amending the filing. In Powell's submissions to district courts in Georgia and Michigan, district was misspelled three different ways on the first pages. Powell's Michigan filing also had numerous formatting errors and misidentified one of her experts. Two Republicans said they had been named as a plaintiff in the Georgia and Wisconsin lawsuits despite not having given permission to be included (although one later agreed to remain as a plaintiff). Powell's lawsuits cited an anonymous witness, referred to as "Spyder" or "Spider", who alleged that American voting systems were "certainly compromised by rogue actors, such as Iran and China". Spyder's real name was redacted from submitted documents; however, a bookmark in the file revealed his identity to be Joshua Merritt, an IT consultant. Although Powell's filings describe Merritt as a former "military intelligence expert", the United States Army Intelligence Center stated that he never worked in military intelligence and had not finished a training course in military intelligence. Merritt acknowledged that the description was wrong and attributed the error to Powell's clerks. However, Merritt claimed he did finish the training, producing an "unofficial transcript" as evidence. Powell also presented an affidavit from an individual she described as a former intelligence contractor with knowledge of a foreign conspiracy to subvert democracy, who Powell said needed to remain anonymous to protect their "reputation, professional career and personal safety". The Washington Post identified the individual as pro-Trump podcaster Terpsichore Maras-Lindeman, and that parts of the affidavit matched a blog post she had written in November 2019. Maras-Lindeman had served in the Navy for less than a year over two decades earlier, and in a November 2018 civil suit the attorney general of North Dakota accused her of misappropriating funds for personal use from a charitable event she tried to organize. State attorneys asserted that she exaggerated her credentials and used multiple aliases and Social Security numbers in "a persistent effort...to deceive others". Asked about Maras-Lindeman, Powell told the Post: "I don't have the same information you do." Arizona Powell filed a federal lawsuit against Arizona governor Doug Ducey, Arizona secretary of state Katie Hobbs and other Arizona election officials on December 2, alleging that "poll watchers failed to adequately verify signatures on ballots, that Maricopa County ballot dispute referees were partisan, that Dominion backups had no chain of custody, and the Dominion machines themselves suffered from errors during state evaluations." The plaintiffs asked the court to decertify Arizona's election results or order that Arizona certify Trump electors. On December 9, U.S. District Judge Diane Humetewa dismissed the case due to plaintiffs' lack of legal standing, and ruled that the allegations of impropriety were "sorely wanting of relevant or reliable evidence", instead being "largely based on anonymous witnesses, hearsay, and irrelevant analysis of unrelated elections". The judge singled out the fraud allegations being put forth, writing that they "fail in their particularity and plausibility" and that there would be "extreme, and entirely unprecedented" harm to Arizona's more than 3 million voters to entertain Powell's lawsuit "at this late date". Powell filed an appeal of the lawsuit's dismissal in the U.S. Court of Appeals for the Ninth Circuit in December, which scheduled the due date for the opening brief to be two months after the inauguration. That month, Powell also filed an emergency petition with the United States Supreme Court seeking an extraordinary writ of mandamus for intervention in the case. The petition was denied without comment on March 1, 2021, ending the matter. Georgia Powell and Lin Wood filed a lawsuit against Georgia governor Brian Kemp and other state officials on November 25, alleging that Dominion Voting Systems was used to rig votes for Biden. The plaintiffs asked the court to halt the certification of elections results and order Kemp to certify Trump as the winner in Georgia. U.S. district judge Timothy Batten issued a temporary restraining order on November 29 that voting machines in Georgia's Cobb, Gwinnett, and Cherokee counties were to preserve their data, after Wood had argued to retain "this information on a very limited basis". Powell appealed to the U.S. Court of Appeals for the Eleventh Circuit to expand the restraining order. A three-judge panel unanimously dismissed Powell's appeal on December 4, citing a failure to prove that the restraining order caused serious harm. The panel also indicated that the original lawsuit, in which Powell also sought to have voting machines inspected, was "considerably delayed" by the appeal. Powell's evidence in the Georgia lawsuit included an affidavit from Ron Watkins, a former administrator of 8chan/8kun, the online home of QAnon. In his affidavit, Watkins stated that his reading of an online user guide for Dominion Voting Systems software led him to conclude that election fraud might be "within the realm of possibility". Watkins did not provide any legitimate evidence of fraud. Powell also claimed that "a certificate from the [Georgia] Secretary of State was awarded to Dominion Voting Systems but is undated." However, the attached certificate had apparently been edited to remove the date; the actual certificate is dated and available publicly. Batten dismissed the case in a ruling from the bench on December 7. The judge ruled that the plaintiffs did not have legal standing to bring the case, filed the case too late (as the Dominion machines were adopted months earlier), and filed the case in the wrong venue, the appropriate venue being a state court. Batten also stated that the relief sought by Powell was impossible to grant. The plaintiffs filed an appeal (Case No. 20-14579) of Batten's decision in the U.S. Court of Appeals for the Eleventh Circuit on December 8. Powell also appealed the decision to the U.S. Supreme Court, which denied a motion to expedite the case. She dropped the lawsuit on January 19, 2021, one day before Biden's inauguration. In August 2022, Fulton County District Attorney Fani Willis sought to have Powell testify before a special grand jury seated for the investigation into possible illegal election interference. Powell was involved in arranging for the collection of data from election systems and voting machines at the county's elections office in rural Coffee County in January 2021. On October 19, 2023, Powell pleaded guilty to six misdemeanor charges for her role in the attempt by the former president and his allies to alter the outcome of the election in the State of Georgia and other states. She will serve six years' probation (one year for each charge) and pay a $6,000 fine. Michigan Powell filed a lawsuit against Michigan governor Gretchen Whitmer and other state officials on November 25, alleging a variety of violations of the election code and asking the court to decertify the state's election results or certify them for Trump. In the lawsuit, Powell submitted a witness's declaration that Joe Biden had "received more than 100% of the votes" in Edison County; however, there is no Edison County in Michigan or any other U.S. state. There is an Edison Township in Minnesota, leading to speculation that the information was again taken from a list of Minnesota precincts. U.S. district judge Linda V. Parker denied the requested relief on December 7, stating that the plaintiffs had only offered "theories, conjecture, and speculation" of potential vote switching. The judge also declared that the "ship has sailed" for most of the relief requested by the plaintiffs, while the rest "is beyond the power of any court". Furthermore, Parker wrote that the relief requested would "greatly harm the public interest" and felt that the plaintiffs' motive for filing the case was not to win, but rather to shake "people's faith in the democratic process and their trust in our government". Powell has filed an appeal of the decision in the U.S. Court of Appeals for the Sixth Circuit, as well as the U.S. Supreme Court, which denied a motion for expedited review of the case. The city of Detroit has called for sanctions against the plaintiffs in the case as well as their counsel, requesting that Powell and the other attorneys be disbarred for "trying to use this court's processes to validate their conspiracy theories". Michigan attorney general Dana Nessel filed a similar motion on January 28, 2021, accusing Powell and three Michigan lawyers of violating their oaths by attempting to overturn Biden's victory. On February 1, 2021, Nessel, along with Michigan governor Whitmer and Michigan secretary of state Jocelyn Benson, filed complaints with the State Bar of Texas seeking Powell's disbarment. During a July 2021 hearing to consider sanctions against Powell and other attorneys for their activities in Michigan, Parker discussed the hundreds of pages of allegations by others that the attorneys had submitted to courts, which included an individual claiming to have witnessed poll workers changing votes from Trump to Biden. None of the attorneys responded when Parker asked if they had spoken to the witness to vet their allegation. On August 25, 2021, Judge Parker ruled that Powell, L. Lin Wood, and seven other pro-Trump lawyers, had filed the suit "in bad faith and for an improper purpose"; that their litigation was a "a historic and profound abuse of the judicial process"; and that they had filed a baseless, frivolous lawsuit in order to undermine public confidence in the democratic process. The court ordered that they pay attorney's fees to the City of Detroit and State of Michigan to reimburse them for the costs of defending against the suit, and referred them to their respective state bars for investigation into ethical violations, which could lead to disbarment. On November 4, 2021, a closed-door investigatory hearing was held by the State Bar of Texas to begin the process of determining possible sanctions or disbarment for Powell. On December 2, 2021, Judge Parker ordered Powell, Wood and the other "Kraken" attorneys to pay $175,250 to the city of Detroit and the state of Michigan. Wisconsin Powell filed a federal lawsuit against the Wisconsin Elections Commission on December 1, claiming that Dominion Voting Systems and Smartmatic were used to conduct electronic ballot-stuffing and rig votes for Joe Biden. The lawsuit asked the court to decertify the state's election results or declare Donald Trump the winner of the state. The lawsuit mistakenly demanded the release of video footage from a voting center in Michigan and made erroneous references to the election in Georgia and the Georgia state legislature. U.S. district judge Pamela Pepper filed a December 2 order noting that while an "expedited" injunction was sought, the initial filings did not "indicate whether the plaintiffs are asking the court to act more quickly or why", and did not request a hearing or propose a briefing schedule. Pepper dismissed the case on December 9, writing that the "federal court has no authority or jurisdiction to grant the relief the remaining plaintiff seeks", and that the litigation on behalf of the plaintiff was "sometimes odd and often harried" and ultimately failed to establish why a federal case was appropriate. Pepper also repeatedly stated that the plaintiff did not have legal standing to bring the case and concluded that granting the relief would be unconstitutional. Powell then applied for a writ of mandamus from the U.S. Supreme Court, which rejected her petition on March 1, 2021, to end the lawsuit; Powell said the court's decision "completes the implosion of each of our three branches of government into the rubble of a sinkhole of corruption". Defamation lawsuits against Powell Dominion Voting Systems sent a letter to Powell on December 16, 2020, demanding she publicly retract her baseless allegations about the company. Shortly thereafter, the Trump legal team instructed dozens of staff members to preserve all documents relating to Dominion, Powell and others for any future litigation. Smartmatic sent a similar demand letter to conservative television outlets and within days Fox News, its sister network Fox Business, as well as Newsmax broadcast segments walking back conspiracy allegations they had previously promoted. On January 8, 2021, Dominion sued Powell for defamation and asked for over $1.3 billion in damages. On February 4, 2021, Smartmatic filed a defamation lawsuit that accused Powell, Fox News, some hosts at Fox News, and Rudy Giuliani of engaging in a "disinformation campaign" against the company, and asked for $2.7 billion in damages. In March 2022 a New York State Supreme Court judge dismissed the Smartmatic allegations against Powell on jurisdictional grounds; however, the company had already filed a second lawsuit in Washington, D.C. in anticipation of the New York ruling. On March 22, 2021, lawyers defending Powell against Dominion's lawsuit filed a motion to dismiss the lawsuit. They argued that "no reasonable person would conclude that the statements [by Powell about the 2020 election] were truly statements of fact". Instead, "it was clear to reasonable persons that Powell's claims were her opinions and legal theories", argued the lawyers. Furthermore, the lawyers claimed that Dominion could not prove that Powell took action with "actual malice", because "she believed the allegations then and she believes them now". On August 11, 2021, Judge Carl Nichols denied this motion to dismiss the lawsuit. A scheduling order filed March 1, 2022, for Dominion's suit against Powell and parallel lawsuits against Rudy Giuliani and My Pillow, Inc., calls for depositions and pretrial motions through September 2023. Venezuelan businessman Majed Khalil sued Powell, Fox News, and Lou Dobbs for $250 million in December 2021, alleging they had falsely implicated him in rigging Dominion and Smartmatic machines. The lawsuit was settled out of court for an undisclosed amount in April 2023. QAnon Powell has been described by some sources as a supporter of the QAnon conspiracy theory, a far-right conspiracy theory which alleges that a cabal of Satan-worshipping pedophiles is running a global child sex-trafficking ring and plotting against former president Donald Trump, who is fighting the cabal. In January 2020, Powell denied knowledge of QAnon or Q; later that year, she retweeted major QAnon accounts and catchphrases and appeared on QAnon shows on YouTube. Upon leaving Trump's legal team, Powell was embraced by QAnon followers, many of whom had become discouraged that years of predictions of a Trump landslide victory and coming revelations about his enemies had not materialized. On January 8, 2021, Twitter permanently suspended the accounts of Powell, Michael Flynn and others. A statement from Twitter said this development was in line with their policies on "coordinated harmful activity". In May 2021, Powell (alongside Lin Wood and Michael Flynn) was a keynote speaker at what was essentially a QAnon conference in Dallas, Texas. Texas Bar petition against Powell On March 1, 2022, the State Bar of Texas’ Commission for Lawyer Discipline submitted in court a disciplinary petition against Powell alleging that she had violated several rules of professional conduct, such as those about making false statements to a tribunal, using evidence known to be false, and engaging in dishonesty, fraud, deceit or misrepresentation. On February 23, 2023, judge Andrea Bouressa of the 471st District Court, dismissed the petition, on the grounds of the commission failing to meet the burden of proof that Powell had indeed violated the Texas' attorney code of conduct. In her decision, the judge also admonished the commission for not "properly labeling" the exhibits in its filing, which led to the consideration of only two of them. Political fundraising In November 2020, Powell established Legal Defense Fund for the American Republic, a 501(c)(4) nonprofit organization with stated purpose to collect funds to help prosecute fraud in U.S. elections. Powell launched Restore the Republic, a super PAC, in January 2021. In November 2021, The Washington Post reported that the preceding September federal prosecutors had issued a subpoena for the financial records of groups Powell had formed, including Defending the Republic, which was registered as a social welfare organization, and a political action committee by the same name. Days after the election, Powell created a website to raise funds for her new organization, referring to "Sidney Powell's Legal Defense Fund," asking donors to make checks payable to her law firm. The Daily Beast reported that the organization's board of directors initially included Michael Flynn and Lin Wood, and Patrick Byrne as CEO. All left the organization in April 2021 after Powell refused to allow it to be audited. In a recorded phone call with Wood that Byrne confirmed as authentic, Byrne asserted Powell was diverting donations to pay for her legal defense against defamation lawsuits. Defending the Republic raised $16.4 million in the year following the election. The group spent millions to fund the legal defense of the January 6 defendants; its expenditures, as well as reduced donations, substantially reduced DTR's cash on hand, but it still has more than $5 million as of November 2022. As a dark money group, Defending the Republic is not required to disclose its donors. Criminal charges and guilty plea As part of the prosecution of Donald Trump in Georgia, on August 14, 2023, she was indicted by a grand jury for violating Georgia's Racketeer Influenced and Corrupt Organizations Act (RICO) statute along with 18 other alleged co-conspirators, including Trump himself. She was also charged with two counts of conspiracy to commit election fraud; and one count of each of the following conspiracies to commit: computer theft, computer trespass, computer invasion of privacy, and defraud the state—for a total of seven felony counts. Powell turned herself in at the Fulton County jail on August 23, 2023. On October 19, 2023, Powell pleaded guilty to six misdemeanor counts related to her role in Trump's attempts to overturn the election and her own role in breaching electoral equipment security in Coffee County, Georgia. She agreed to a sentence of six years' probation, a $6,000 fine and $2,700 in restitution, and to write a letter of apology to the people of Georgia. She will also testify in other cases. Within a week, Trump claimed that Powell was "not my attorney, and never was", despite his November 2020 Twitter statement that "Sidney Powell ... [has been] added to our other wonderful lawyers and representatives". Powell's guilty plea was generally analyzed in American news media as a major victory for prosecutors against Trump and his associates. The New York Times' Alan Feuer and Maggie Haberman noted Powell as the first time that prosecutors collaborated with a major co-conspirator of Trump's attempts to overturn the election. Both also noted the potential for Powell's guilty plea to legitimize other criminal charges against other figures involved in both Georgia's racketeering cases and Jack Smith's federal charges against Trump and his associates. The Atlantic echoed these concerns, with journalist David A. Graham comparing the relationship between Powell's plea and the other figures charged in the Georgia racketeering case to the prisoner's dilemma. Likewise, CNN analyst Marshall Cohen viewed the Powell plea as having the potential to incriminate anyone who worked with Powell during the attempts to overturn the election, though Cohen said that the plea deal in Georgia could open up Powell to prosecution by Jack Smith and a potential second plea deal with him, where she is alluded to as an unindicted co-conspirator. Alternatively, PBS News Georgia correspondent Stephen Fowler said Powell's testimony was potentially unreliable, and cited Trump's lawyer's assertion that Powell's testimony would exonerate the former president. Writing Powell has written opinion pieces for The New York Observer, The Daily Caller, The Hill, National Review, Fox News, and media organizations and conservative content producers. She has written two published books: In addition, she has published several journal articles on law practice. Examples include: Personal life and other ventures Powell has a son from a marriage that ended in divorce "decades ago". In 2004, she founded a non-profit for victims of domestic violence. She has participated in volunteer work for women's shelters and other charities. Powell was not recalled as "being a staunch conservative or even very political" by people who interacted with her in those organizations. Powell served as executive producer on the 2013 drama Decoding Annie Parker, providing guidance to help bring the film to a commercial release. The film tells the story of Annie Parker and the discovery of the BRCA1 breast cancer gene. Powell oversaw fundraising screenings for the film that raised approximately $1 million for breast cancer charities. See also List of alleged Georgia election racketeers References External links 1955 births Living people 20th-century American lawyers 20th-century American women writers 21st-century American lawyers 21st-century American women writers American conspiracy theorists American political writers Lawyers from Dallas People from Durham, North Carolina Lawyers from Raleigh, North Carolina QAnon Texas Republicans University of North Carolina alumni University of North Carolina School of Law alumni Writers from North Carolina The State of Georgia v. Donald J. Trump, et al. defendants Donald Trump attorneys 21st-century American criminals
Lissotis is a genus of bird in the bustard family, Otididae. Some authorities, such as the IUCN, consider it part of Eupodotis; the separation adopted here follows the Handbook of the Birds of the World. It contains the following species, both restricted to Africa: References Taxa named by Ludwig Reichenbach
Juze or Juje is a 2017 Indian film in Konkani, written and directed by Miransha Naik. The film is about the social injustice and exploitation faced by migrant labourers in Goa, and is set in the 1990s. It was co-produced by people from India, France and Netherlands (Thin Air, Three Rivers, Kepler Films, Cine-Sud Promotion) under the banner of Goa Film Bazaar, with some of the editing done in Paris. The film premiered at the Hong Kong International Film Festival in April 2017, and was also chosen for the Karlovy Vary Film Festival. It became the first Konkani film to be commercially released in France. Juze also became the first Konkani film to be selected for mentoring and promotion during Film Bazaar, the filmmaking lab organised by National Film Development Corporation (NFDC) in Goa, in 2015. It was featured at the Mumbai Film Festival in October 2017, at the 48th International Film Festival of India (IFFI) in the Indian Panorama section in November 2017, the Minsk Film Festival in Belarus (where it won an award) and the Dublin International Film Festival in Ireland. The film was finally released in Goa, with an "A" certification by the Central Board of Film Certification (CBFC), in April 2018. Plot The story is set in the 1990s. Santosh (Rushikesh Naik) is a teenage boy studying in Class X. He lives in a slum in Borimol village with his grandmother, referred to as Tai (played by Prashanti Talpankar; Tai translates to "aunt"). It is revealed that Tai's son, Santosh's father, had killed Santosh's mother and had been arrested, leaving Tai and Santosh to fend for themselves. Thus, despite being native Goans, they are forced to live with other migrants from poorer parts of the country and work for Juze (Sudesh Bhise). With his business of manufacturing cashew feni and his political connections (which consist of the local politician), Juze terrorizes the whole village, even going so far as to physically abuse and rape the women. Santosh is an intelligent boy and scores well in class. He frequently skips work to go to school. This frequently gets him in trouble with Juze, who often beats him up publicly. Juze's wife Maria (Gauri Kamat) recognizes Santosh's intelligence and demands that he help her son, who is weak in studies. She also forces him to perform sexual favours for her. Meanwhile, Santosh has a budding romance with his classmate, Maya (Barkha Naik). However, their relationship slowly breaks apart when she realizes the helplessness of his situation. All of this ultimately leads to Santosh confronting Juze with a friend and beating him to death. Santosh then runs away from the village, and is seen waiting tables at a beachside shack. Cast Rushikesh Naik as Santosh Prashanti Talpankar as Tai, Santosh's grandmother Sudesh Bhise as Juze Gauri Kamat as Maria, Juze's wife Barkha Naik as Maya Production The film is partially based on writer-director Miransha Naik's childhood experiences. The film is set in the 90s, making the character Santosh the same age as Miransha was then. The film is also set in Naik's hometown of Borimol village. He admits that some of the events and characters have been adapted from real life. He named the movie after the villain as he found it unique. He believes that the events revolve around Juze, and even though the movie is about Santosh's journey, it simultaneously portrays the downfall of Juze. It may be noted that Naik lost both his parents to illness at the age of 9. He grew up in Borimol along with his grandmother and two sisters, coming third in his Class X exams. He dropped out within a year of joining the BCom course at Government College, Quepem, to contribute to his household by working as a waiter. His grandmother passed away when he was 19, and he had to take responsibility of the marriages of his two sisters. By waiting tables for nearly five years, he made enough money to set up his own beachside shack, named Blue Corner, on Benaulim Beach. Two scenes in Juze show the village children watching Subhash Ghai's Karz and Hero, which is reminiscent of Naik and his young friends and his love for movies. Initially, Naik chose a Mumbai-based actor for the role of Juze's wife, Maria, as he wasn't confident that local artistes would be up to a role with a number of sex scenes. However, the chosen actor couldn't perform because of her language barrier. Naik then turned to Gauri Kamat upon many recommendations, and after some initial hesitation, she agreed to play the part. However, by late 2015, they faced an even bigger problem: shortage of funds even before post-production. It was then that Naik thought of National Film Development Corporation’s annual "Film Bazaar", where it attracted the attention of noted producer Olivia Stewart, who procured funds from the Netherlands-based production company Keplerfilm and the France-based production company of Cine-Sud Promotions. Christian Jeune, who is famous as a scout for Cannes Film Festival, was also impressed with the film's idea, and the film almost made it to Cannes’ Un Certain Regard selection. The film shows all the interesting developments (including that of his relationship with Maria and Maya) through clever and subtle camerawork, including a series of tracking shots, portraying how Santosh nonchalantly sees all this as a part of his daily life. Reception Critical response The film was well received by critics for portraying the lesser-known culture and exploitation of the poorer classes taking place in Goa (which is otherwise portrayed very glamorously in films). Clarence Tsui of The Hollywood Reporter called the film a "contemplative and topical debut, with a story offering mostly heartbreak but also a faint glimpse of hope." Nikki Baughan of ScreenDaily wrote, "Juze may be an exploration of an existence which is endured, rather than lived, but there’s no trace of melodrama or didacticism." Notably, Juze was screened at the Hong Kong International Film Festival, the Karlovy Vary Film Festival, the Mumbai Film Festival, the International Film Festival of India, the Minsk Film Festival and the Dublin International Film Festival. Awards Special Jury Award at Minsk Film Festival, 2017 (director, Miransha Naik) See also Konkani cinema Paltadacho Munis Nachom-ia Kumpasar References External links 2017 films Films set in Goa Films shot in Goa 2010s Konkani-language films
```html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "path_to_url"> <html xmlns="path_to_url"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.17"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>Jetson Inference: jetson-utils/cudaFilterMode.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectlogo"><img alt="Logo" src="NVLogo_2D.jpg"/></td> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">Jetson Inference </div> <div id="projectbrief">DNN Vision Library</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.17 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */ var searchBox = new SearchBox("searchBox", "search",false,'Search'); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */</script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('cudaFilterMode_8h_source.html',''); initResizable(); }); /* @license-end */ </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="headertitle"> <div class="title">cudaFilterMode.h</div> </div> </div><!--header--> <div class="contents"> <a href="cudaFilterMode_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">/*</span></div> <div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment"> *</span></div> <div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</span></div> <div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment"> * copy of this software and associated documentation files (the &quot;Software&quot;),</span></div> <div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment"> * to deal in the Software without restriction, including without limitation</span></div> <div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</span></div> <div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</span></div> <div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment"> * Software is furnished to do so, subject to the following conditions:</span></div> <div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment"> *</span></div> <div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="comment"> * The above copyright notice and this permission notice shall be included in</span></div> <div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="comment"> * all copies or substantial portions of the Software.</span></div> <div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="comment"> *</span></div> <div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="comment"> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div> <div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div> <div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</span></div> <div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div> <div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span></div> <div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span></div> <div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="comment"> * DEALINGS IN THE SOFTWARE.</span></div> <div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="comment"> */</span></div> <div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160; </div> <div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="preprocessor">#ifndef __CUDA_FILTER_MODE_H__</span></div> <div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;<span class="preprocessor">#define __CUDA_FILTER_MODE_H__</span></div> <div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160; </div> <div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; </div> <div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="cudaUtility_8h.html">cudaUtility.h</a>&quot;</span></div> <div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160; </div> <div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160; </div> <div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="group__cudaFilter.html#ga25d4283643163befe99948d24cc53311"> 35</a></span>&#160;<span class="keyword">enum</span> <a class="code" href="group__cudaFilter.html#ga25d4283643163befe99948d24cc53311">cudaFilterMode</a></div> <div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;{</div> <div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="group__cudaFilter.html#your_sha256_hashdaa6"> 37</a></span>&#160; <a class="code" href="group__cudaFilter.html#your_sha256_hashdaa6">FILTER_POINT</a>, </div> <div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="group__cudaFilter.html#your_sha256_hash5094"> 38</a></span>&#160; <a class="code" href="group__cudaFilter.html#your_sha256_hash5094">FILTER_LINEAR</a> </div> <div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160;};</div> <div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; </div> <div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160;<a class="code" href="group__cudaFilter.html#ga25d4283643163befe99948d24cc53311">cudaFilterMode</a> <a class="code" href="group__cudaFilter.html#ga6a34c93022b23a55a5ae440a8ff7a247">cudaFilterModeFromStr</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* filter, <a class="code" href="group__cudaFilter.html#ga25d4283643163befe99948d24cc53311">cudaFilterMode</a> default_value=<a class="code" href="group__cudaFilter.html#your_sha256_hash5094">FILTER_LINEAR</a> );</div> <div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; </div> <div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;<span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="group__cudaFilter.html#gaf0051762a62125939ddbd5c38417f3ff">cudaFilterModeToStr</a>( <a class="code" href="group__cudaFilter.html#ga25d4283643163befe99948d24cc53311">cudaFilterMode</a> filter );</div> <div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; </div> <div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; </div> <div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="group__cudaFilter.html#ga66fe4a27e9fb59cd675d5deb12287195"> 59</a></span>&#160;<span class="keyword">enum</span> <a class="code" href="group__cudaFilter.html#ga66fe4a27e9fb59cd675d5deb12287195">cudaDataFormat</a></div> <div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160;{</div> <div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="group__cudaFilter.html#your_sha256_hashfc6a"> 61</a></span>&#160; <a class="code" href="group__cudaFilter.html#your_sha256_hashfc6a">FORMAT_HWC</a>, </div> <div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="group__cudaFilter.html#your_sha256_hasha51a"> 62</a></span>&#160; <a class="code" href="group__cudaFilter.html#your_sha256_hasha51a">FORMAT_CHW</a>, </div> <div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="group__cudaFilter.html#your_sha256_hashdece"> 65</a></span>&#160; <a class="code" href="group__cudaFilter.html#your_sha256_hashdece">FORMAT_DEFAULT</a> = <a class="code" href="group__cudaFilter.html#your_sha256_hashfc6a">FORMAT_HWC</a></div> <div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160;};</div> <div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; </div> <div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; </div> <div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160;<span class="preprocessor">#endif</span></div> <div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; </div> <div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; </div> </div><!-- fragment --></div><!-- contents --> </div><!-- doc-content --> <div class="ttc" id="agroup__cudaFilter_html_ga6a34c93022b23a55a5ae440a8ff7a247"><div class="ttname"><a href="group__cudaFilter.html#ga6a34c93022b23a55a5ae440a8ff7a247">cudaFilterModeFromStr</a></div><div class="ttdeci">cudaFilterMode cudaFilterModeFromStr(const char *filter, cudaFilterMode default_value=FILTER_LINEAR)</div><div class="ttdoc">Parse a cudaFilterMode enum from a string.</div></div> <div class="ttc" id="acudaUtility_8h_html"><div class="ttname"><a href="cudaUtility_8h.html">cudaUtility.h</a></div></div> <div class="ttc" id="agroup__cudaFilter_html_ga66fe4a27e9fb59cd675d5deb12287195"><div class="ttname"><a href="group__cudaFilter.html#ga66fe4a27e9fb59cd675d5deb12287195">cudaDataFormat</a></div><div class="ttdeci">cudaDataFormat</div><div class="ttdoc">Enumeration of image layout formats.</div><div class="ttdef"><b>Definition:</b> cudaFilterMode.h:59</div></div> <div class="ttc" id=your_sha256_hashde74ec16a7e07145b7c18c885094"><div class="ttname"><a href="group__cudaFilter.html#your_sha256_hash5094">FILTER_LINEAR</a></div><div class="ttdeci">@ FILTER_LINEAR</div><div class="ttdoc">Bilinear filtering.</div><div class="ttdef"><b>Definition:</b> cudaFilterMode.h:38</div></div> <div class="ttc" id="agroup__cudaFilter_html_gaf0051762a62125939ddbd5c38417f3ff"><div class="ttname"><a href="group__cudaFilter.html#gaf0051762a62125939ddbd5c38417f3ff">cudaFilterModeToStr</a></div><div class="ttdeci">const char * cudaFilterModeToStr(cudaFilterMode filter)</div><div class="ttdoc">Convert a cudaFilterMode enum to a string.</div></div> <div class="ttc" id=your_sha256_hash6f5b6af6f76d13ef2aefd17ea51a"><div class="ttname"><a href="group__cudaFilter.html#your_sha256_hasha51a">FORMAT_CHW</a></div><div class="ttdeci">@ FORMAT_CHW</div><div class="ttdoc">Channels * Width * Height (DNN format)</div><div class="ttdef"><b>Definition:</b> cudaFilterMode.h:62</div></div> <div class="ttc" id=your_sha256_hashed98915affb5c7514632a038daa6"><div class="ttname"><a href="group__cudaFilter.html#your_sha256_hashdaa6">FILTER_POINT</a></div><div class="ttdeci">@ FILTER_POINT</div><div class="ttdoc">Nearest-neighbor sampling.</div><div class="ttdef"><b>Definition:</b> cudaFilterMode.h:37</div></div> <div class="ttc" id="agroup__cudaFilter_html_ga25d4283643163befe99948d24cc53311"><div class="ttname"><a href="group__cudaFilter.html#ga25d4283643163befe99948d24cc53311">cudaFilterMode</a></div><div class="ttdeci">cudaFilterMode</div><div class="ttdoc">Enumeration of interpolation filtering modes.</div><div class="ttdef"><b>Definition:</b> cudaFilterMode.h:35</div></div> <div class="ttc" id=your_sha256_hashdb7b40bd34c9b4e91df46d37fc6a"><div class="ttname"><a href="group__cudaFilter.html#your_sha256_hashfc6a">FORMAT_HWC</a></div><div class="ttdeci">@ FORMAT_HWC</div><div class="ttdoc">Height * Width * Channels (packed format)</div><div class="ttdef"><b>Definition:</b> cudaFilterMode.h:61</div></div> <div class="ttc" id=your_sha256_hasha0e14adcf61d8fdc4df73a29dece"><div class="ttname"><a href="group__cudaFilter.html#your_sha256_hashdece">FORMAT_DEFAULT</a></div><div class="ttdeci">@ FORMAT_DEFAULT</div><div class="ttdef"><b>Definition:</b> cudaFilterMode.h:65</div></div> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="navelem"><a class="el" href="dir_54a0acf6da04fe2ed9410b4c6369bc5d.html">jetson-utils</a></li><li class="navelem"><a class="el" href="cudaFilterMode_8h.html">cudaFilterMode.h</a></li> <li class="footer">Generated on Tue Mar 28 2023 14:27:58 for Jetson Inference by <a href="path_to_url"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li> </ul> </div> </body> </html> ```
```java /* */ package akka.http.javadsl.coding; import java.util.concurrent.CompletionStage; import akka.http.javadsl.model.HttpRequest; import akka.http.javadsl.model.HttpResponse; import akka.stream.Materializer; import akka.util.ByteString; import scala.compat.java8.FutureConverters; /** * A coder is an implementation of the predefined encoders/decoders defined for HTTP. */ @SuppressWarnings({"deprecation", "removal"}) public enum Coder { NoCoding(akka.http.scaladsl.coding.NoCoding$.MODULE$), Deflate(akka.http.scaladsl.coding.Deflate$.MODULE$), Gzip(akka.http.scaladsl.coding.Gzip$.MODULE$), DeflateLevel1(akka.http.scaladsl.coding.Deflate$.MODULE$.withLevel(1)), DeflateLevel9(akka.http.scaladsl.coding.Deflate$.MODULE$.withLevel(9)), GzipLevel1(akka.http.scaladsl.coding.Gzip$.MODULE$.withLevel(1)), GzipLevel9(akka.http.scaladsl.coding.Gzip$.MODULE$.withLevel(9)); private akka.http.scaladsl.coding.Coder underlying; Coder(akka.http.scaladsl.coding.Coder underlying) { this.underlying = underlying; } public HttpResponse encodeMessage(HttpResponse message) { return (HttpResponse) underlying.encodeMessage((akka.http.scaladsl.model.HttpMessage) message); } public HttpRequest encodeMessage(HttpRequest message) { return (HttpRequest) underlying.encodeMessage((akka.http.scaladsl.model.HttpMessage) message); } /** * @deprecated Synchronous encoding is deprecated since 10.2.0 */ @Deprecated public ByteString encode(ByteString input) { return underlying.encode(input); } public HttpResponse decodeMessage(HttpResponse message) { return (HttpResponse) underlying.decodeMessage((akka.http.scaladsl.model.HttpMessage) message); } public HttpRequest decodeMessage(HttpRequest message) { return (HttpRequest) underlying.decodeMessage((akka.http.scaladsl.model.HttpMessage) message); } public CompletionStage<ByteString> decode(ByteString input, Materializer mat) { return FutureConverters.toJava(underlying.decode(input, mat)); } public akka.http.scaladsl.coding.Coder _underlyingScalaCoder() { return underlying; } } ```