Skip to main content
Log in

MiniBrass: Soft constraints for MiniZinc

  • Published:
Constraints Aims and scope Submit manuscript

Abstract

Over-constrained problems are ubiquitous in real-world decision and optimization problems. Plenty of modeling formalisms for various problem domains involving soft constraints have been proposed, such as weighted, fuzzy, or probabilistic constraints. All of them were shown to be instances of algebraic structures. In terms of modeling languages, however, the field of soft constraints lags behind the state of the art in classical constraint optimization. We introduce MiniBrass, a versatile soft constraint modeling language building on the unifying algebraic framework of partially ordered valuation structures (PVS) that is implemented as an extension of MiniZinc and MiniSearch. We first demonstrate the adequacy of PVS to naturally augment partial orders with a combination operation as used in soft constraints. Moreover, we provide the most general construction of a c-semiring from an arbitrary PVS. Both arguments draw upon elements from category theory. MiniBrass turns these theoretical considerations into practice: It offers a generic extensible PVS type system, reusable implementations of specific soft constraint formalisms as PVS types, operators for complex PVS products, and morphisms to transform PVS. MiniBrass models are compiled into MiniZinc to benefit from the wide range of solvers supporting FlatZinc. We evaluated MiniBrass on 28 “softened” MiniZinc benchmark problems with six different solvers. The results demonstrate the feasibility of our approach.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Listing 1
Listing 2
Listing 3
Fig. 6
Listing 4
Fig. 7

Similar content being viewed by others

Notes

  1. Evidenced by the fact that at the Third International CSP Competition (CPAI’08), Toulbar2 was the only solver registered for the weighted CSP (WCSP) category—with none in the (last) ’09 edition.

  2. MiniBrass pays tribute to the tradition of naming NICTA’s G12 software after elements in the 12th group of the periodic table. Brass is an alloy containing zinc that is softer than zinc alone.

  3. This relation is, in its set version, used to express non-determinism of programs in denotational semantics (set-valued to “collect different program results”), i.e., so-called power domains [4, Ch. 9].

  4. Interestingly enough, the fact that partial valuation structures need not be idempotent in general (e.g., weighted constraints) disallows a straightforward extension of local consistency to soft constraints [18].

  5. Curiously enough, the Smyth-ordering on mere sets is not antisymmetric. It is just a preorder.

  6. Obviously, in a total ordering, the supremum is just min/max.

  7. https://github.com/isse-augsburg/minibrass

  8. Note that the encoding employs a table constraint for floats which is not supported well by many solvers. Therefore a workaround using integers is also provided in the MiniBrass library that can be seen as another example for a PVS type representing a different one.

  9. https://github.com/MiniZinc/minizinc-benchmarks

  10. https://carlit.toulouse.inra.fr/cgi-bin/awki.cgi/BenchmarkS and https://github.com/MiniZinc/minizinc-benchmarks/blob/master/proteindesign12/wcsp.mznhttps://github.com/MiniZinc/minizinc-benchmarks/blob/master/proteindesign12/wcsp.mzn

  11. https://github.com/isse-augsburg/minibrass/tree/master/evaluation/problems

  12. We experimented with large neighborhood search as well but did not find it to be effective enough for the selected evaluation problems.

  13. The fact that Choco shows a higher average objective on Photo Placement albeit claiming to have proved optimality results from a bug in the solver induced by the problem-specific search heuristics.

  14. Note that the “objective values” for the Smyth-model are provided only for comparative reasons. Optimization was done purely according to the Smyth-ordering on the set of violated soft constraints.

  15. Certainly, some global constraints cannot be reified directly yet, only support half-reification or need a decomposition but we expect them to increasingly do so [9].

References

  1. Allen, T.E., Chen, M., Goldsmith, J., Mattei, N., Popova, A., Regenwetter, M., Rossi, F., Zwilling, C. (2015). Beyond theory and data in preference modeling: bringing humans into the loop. In T. Walsh (Ed.) Proceedings of the 4th international conference on algorithmic decision theory (ADT’15). Lecture notes in computer science (Vol. 9346, pp. 3–18). Berlin: Springer.

  2. Allouche, D, de Givry, S., Schiex, T. (2010). Toulbar2, an open-source exact cost function network solver. Tech. rep., INRIA.

  3. Allouche, D, de Givry, S., Katsirelos, G., Schiex, T., Zytnicki, M. (2015). Anytime hybrid best-first search with tree decomposition for weighted CSP. In G. Pesant (Ed.) Proceedings of the 21st international conference on principles and practice of constraint programming (CP’15). Lecture notes in computer science (Vol. 9255, pp. 12–29). Berlin: Springer.

  4. Amadio, R.M., & Curien, P.L. (1998). Domains and Lambda-Calculi. Cambridge Tracts in Theoretical Computer Science 46. Cambridge: Cambridge University Press.

    Book  Google Scholar 

  5. Ansótegui, C., Bofill, M., Palahí, M., Suy, J., Villaret, M. (2011). W-minizinc: a proposal for modeling weighted CSPs with MiniZinc. In Proceedings of the 1st international workshop on MiniZinc (MZN’11).

  6. Ansótegui, C., Bofill, M., Palahí, M., Suy, J., Villaret, M. (2013). Solving weighted CSPs with meta-constraints by reformulation into satisfiability modulo theories. Constraints, 18(2), 236–268.

    Article  MathSciNet  MATH  Google Scholar 

  7. Awodey, S. (2010). Category theory. Oxford: Oxford University Press.

    MATH  Google Scholar 

  8. Barr, M., & Wells, C. (1990). Category theory for computing science. Englewood Cliffs: Prentice Hall.

    MATH  Google Scholar 

  9. Beldiceanu, N., Carlsson, M., Flener, P., Pearson, J. (2013). On the reification of global constraints. Constraints, 18(1), 1–6.

    Article  MathSciNet  MATH  Google Scholar 

  10. Bertele, U., & Brioschi, F. (1973). On non-serial dynamic programming. Journal of Combinatorial Theory Series A, 14(2), 137–148.

    Article  MathSciNet  MATH  Google Scholar 

  11. Bistarelli, S. (2004). Semirings for soft constraint solving and programming. Lecture notes in computer science Vol. 2962. Berlin: Springer.

    Google Scholar 

  12. Bistarelli, S., Montanari, U., Rossi, F. (1997). Semiring-based constraint satisfaction and optimization. Journal of the ACM, 44(2), 201–236.

    Article  MathSciNet  MATH  Google Scholar 

  13. Bistarelli, S., Montanari, U., Rossi, F., Schiex, T., Verfaillie, G., Fargier, H. (1999). Semiring-based CSPs and valued CSPs: Frameworks, properties, and comparison. Constraints, 4(3), 199–240.

    Article  MathSciNet  MATH  Google Scholar 

  14. Bistarelli, S., Fung, S.K.L., Lee, J.H.M., Leung, H. (2003). A local search framework for semiring-based constraint satisfaction problems. In Proceedings of the workshop on soft constraints (Soft’03).

  15. Borning, A., Freeman-Benson, B., Wilson, M. (1992). Constraint hierarchies. LISP and Symbolic Computation, 5, 223–270.

    Article  MATH  Google Scholar 

  16. Boutilier, C., Brafman, R.I., Domshlak, C., Hoos, H.H., Poole, D. (2004). CP-nets: a tool for representing and reasoning with conditional ceteris paribus preference statements. Journal of Artificial Intelligence Research, 21, 135–191.

    Article  MathSciNet  MATH  Google Scholar 

  17. Brandt, F., Conitzer, V., Endriss, U. (2013). Computational social choice. In G. Weiß (Ed.) Multiagent systems, 2nd edn, chapter 6 (pp. 213–283). MIT Press.

  18. Cooper, M.C., & Schiex, T. (2004). Arc consistency for soft constraints. Artificial Intelligence, 154(1), 199–227.

    Article  MathSciNet  MATH  Google Scholar 

  19. Cooper, M.C, de Givry, S., Sánchez, M., Schiex, T., Zytnicki, M., Werner, T. (2010). Soft arc consistency revisited. Artificial Intelligence, 174(7), 449–478.

    Article  MathSciNet  MATH  Google Scholar 

  20. Dalla Pozza, G., Pini, M.S., Rossi, F., Venable, K.B. (2011). Multi-agent soft constraint aggregation via sequential voting. In T. Walsh (Ed.) Proceedings of the 22nd international joint conference on artificial intelligence (IJCAI’11). IJCAI/AAAI (pp. 172–177).

  21. Dechter, R. (1999). Bucket elimination: a unifying framework for reasoning. Artificial Intelligence, 113(1), 41–85.

    Article  MathSciNet  MATH  Google Scholar 

  22. Dechter, R. (2003). Constraint processing. San Mateo: Morgan Kaufmann.

    MATH  Google Scholar 

  23. Diaconescu, R. (1994). Category-based semantics for equational and constraint logic programming. Ph.D. thesis, Oxford University, Oxford.

  24. Fargier, H., & Lang, J. (1993). Uncertainty in constraint satisfaction problems: a probabilistic approach. In M. Clarke, R. Kruse, S. Moral (Eds.) Proceedings of the european conference symbolic and quantitative approaches to reasoning and uncertainty . Lecture notes in computer science (Vol. 747, pp. 97–104). Berlin: Springer.

  25. Fioretto, F., Pontelli, E., Yeoh, W. (2016). Distributed constraint optimization problems and applications: a survey. CoRR arXiv:1602.06347.

  26. Fleming, P.J., & Wallace, J.J. (1986). How not to lie with statistics: the correct way to summarize benchmark results. Communications of the ACM, 29(3), 218–221.

    Article  Google Scholar 

  27. Freuder, E.C., & Wallace, R.J. (1992). Partial constraint satisfaction. Artificial Intelligence, 58(1–3), 21–70.

    Article  MathSciNet  Google Scholar 

  28. Frisch, A.M., Harvey, W., Jefferson, C., Martínez-Hernández, B., Miguel, I. (2008). Essence: a constraint language for specifying combinatorial problems. Constraints, 13(3), 268–306.

    Article  MathSciNet  MATH  Google Scholar 

  29. Gadducci, F., Hölzl, M., Monreale, G.V., Wirsing, M. (2013). Soft constraints for lexicographic orders. In F. Castro, A. Gelbukh, M. González (Eds.) Proceedings of the 12th Mexican international conference on artificial intelligence (MICAI’2013). Lecture notes in computer science (Vol. 8265, pp. 68–79). Berlin: Springer.

  30. Google optimization tools. https://developers.google.com/optimization. [Online, Accessed: 29 June 2017.

  31. Guns, T., Dries, A., Nijssen, S., Tack, G., De Raedt, L. (2017). MiningZinc: a declarative framework for constraint-based mining. Artificial Intelligence, 244, 6–29.

    Article  MathSciNet  MATH  Google Scholar 

  32. Hebrard, E., O’Mahony, E., O’Sullivan, B. (2010). Constraint programming and combinatorial optimisation in Numberjack. In A. Lodi, M. Milano, P. Toth (Eds.) Proceedings of the 7th international conference on integration of AI and OR techniques in constraint programming for combinatorial optimization problems (CPAIOR’10). Lecture notes in computer science (Vol. 6140, pp. 181–185). Berlin: Springer.

  33. Hosobe, H. (2009). Constraint hierarchies as semiring-based CSPs. In Proceedings of the 21st international conference on tools with artificial intelligence (ICTAI’2009) (pp. 176–183).

  34. Hurley, B., O’Sullivan, B., Allouche, D., Katsirelos, G., Schiex, T., Zytnicki, M, de Givry, S. (2016). Multi-language evaluation of exact solvers in graphical model discrete optimization. Constraints, 21(3), 413–434.

    Article  MathSciNet  MATH  Google Scholar 

  35. Junker, U. (2009). Outer branching: how to optimize under partial orders? In V. Barichard, M. Ehrgott, X. Gandibleux, V. T’Kindt (Eds.) Proceedings of the 7th international conference on multiobjective programming and goal programming (MOPGP’06). Lecture notes in economics and mathematical systems (Vol. 618, pp. 99–109). Berlin: Springer.

  36. Jussien, N., Rochart, G., Lorca, X. (2008). Choco: an open-source Java constraint programming library. In Proceedings of the workshop on open-source software for integer and constraint programming (OSSICP’08) (pp. 1–10).

  37. Kaci, S. (2011). Working with preferences: less is more. Berlin: Springer.

    Book  MATH  Google Scholar 

  38. Kießling, W., & Köstler, G. (2002). Preference SQL: design, implementation, experiences. In Proceedings of the 28th international conference on very large data bases (VLDB’02) (pp. 990–1001). San Mateo: Morgan Kaufmann.

  39. Knapp, A., Schiendorfer, A., Reif, W. (2014). Quality over quantity in soft constraints. In Proceedings of the 26th international conference on tools with artificial intelligence (ICTAI’2014) (pp. 453–460).

  40. Kuchcinski, K., & Szymanek, R. (2013). JaCoP—Java constraint programming solver. In Proceedings of the workshop on CP solvers: modeling, applications, integration, and standardization.

  41. Leenen, L., Anbulagan, A, Meyer, T., Ghose, A.K. (2007). Modeling and solving semiring constraint satisfaction problems by transformation to weighted semiring Max-SAT. In M.A. Orgun, & J. Thornton (Eds.) Proceedings of the 20th Australian joint conference on artificial intelligence. Lecture Notes in Computer Science (Vol. 4830, pp. 202–212). Berlin: Springer.

  42. Mears, C., Schutt, A., Stuckey, P.J., Tack, G., Marriott, K., Wallace, M. (2014). Modelling with option types in MiniZinc. In H. Simonis (Ed.) Proceedings of the 11th international conference on integration of artificial intelligence and operations research techniques in constraint programming (CPAIOR’14), Lecture notes in computer science (Vol. 8451, pp. 88–103). Berlin: Springer.

  43. Meseguer, P., Rossi, F., Schiex, T. (2006). Soft constraints. In F. Rossi, P. van Beek, T. Walsh (Eds.) Handbook of constraint programming, chap. 9. Amsterdam: Elsevier.

  44. Nethercote, N., Stuckey, P.J., Becket, R., Brand, S., Duck, G.J., Tack, G. (2007). MiniZinc: towards a standard CP modelling language. In C. Bessière (Ed.) Proceedings of the 13th international conference on principles and practice of constraint programming (CP’07). Lecture notes in computer science (Vol. 4741, pp. 529–543). Berlin: Springer.

  45. Nisan, N., & Ronen, A. (1999). Algorithmic mechanism design. In J.S. Vitter, L.L. Larmore, F.T. Leighton (Eds.) Proceedings of the 31st annual ACM symposium on theory of computing (STACS’99) (pp. 129–140). ACM.

  46. Petit, T., Régin, J.C., Bessière, C. (2000). Meta-constraints on violations for over constrained problems. In Proceedings of the 12th international conference on tools with artificial intelligence (ICTAI’00) (pp. 358–365).

  47. Pierce, B.C. (1991). Basic category theory for computer scientists. Cambridge: MIT Press.

    MATH  Google Scholar 

  48. Rendl, A., Tack, G., Stuckey, P.J. (2014). Stochastic MiniZinc. In B. O’Sullivan (Ed.) Proceedings of the 20th international conference on principles and practice of constraint programming (CP’14), Lecture Notes in Computer Science (Vol. 8656, pp. 636–645). Berlin: Springer.

  49. Rendl, A., Guns, T., Stuckey, P.J., Tack, G. (2015). MiniSearch: a solver-independent meta-search language for MiniZinc. In G. Pesant (Ed.) Proceedings of the 21st international conference on constraint programming (CP’15), Lecture Notes in Computer Science (Vol. 9255, pp. 376–392).

  50. Rollón, E. (2008). Multi-objective optimization in graphical models. Ph.D. thesis, Universitat Politècnica de Catalunya, Barcelona.

  51. Rossi, F., & Pilan, I. (2003). Abstracting soft constraints: Some experimental results on fuzzy CSPs. In K.R. Apt, F. Fages, F. Rossi, P. Szeredi, J. Váncza (Eds.) Selected papers joint ERCIM/CologNET international workshop on constraint solving and constraint logic programming (CSCLP’03). Lecture notes in computer science (Vol. 3010, pp. 107–123). Berlin: Springer.

  52. Ruttkay, Z. (1994). Fuzzy constraint satisfaction. In Proceedings of the 3rd IEEE international fuzzy systems conference (pp. 1263–1268). IEEE.

  53. Sánchez, M., Allouche, D, de Givry, S., Schiex, T. (2009). Russian doll search with tree decomposition. In C. Boutilier (Ed.) Proceedings of the 21st international joint conference on artificial intelligence (IJCAI’09) (pp. 603–608).

  54. Sannella, D., & Tarlecki, A. (2012). Foundations of algebraic specification and formal software development. EATCS monographs in theoretical computer science. Berlin: Springer.

    Book  MATH  Google Scholar 

  55. Schiendorfer, A., Steghöfer, J.P., Knapp, A., Nafz, F., Reif, W. (2013). Constraint relationships for soft constraints. In M. Bramer, & M. Petridis (Eds.) Proceedings of the 33rd SGAI international conference on innovative techniques and applications of artificial intelligence (AI’13) (pp. 241–255). Berlin: Springer.

  56. Schiendorfer, A., Steghöfer, J.P., Reif, W. (2014). Synthesis and abstraction of constraint models for hierarchical resource allocation problems. In Proceedings of the 6th international conference on agents and artificial intelligence (ICAART’14) (Vol. 2, pp. 15–27). SciTePress.

  57. Schiendorfer, A., Knapp, A., Steghöfer, J.P., Anders, G., Siefert, F., Reif, W. (2015). Partial valuation structures for qualitative soft constraints. In R.D. Nicola, & R. Hennicker (Eds.) Software, services and systems—essays dedicated to Martin Wirsing on the occasion of his emeritation, Lecture Notes in Computer Science (Vol. 8950, pp. 115–133). Berlin: Springer.

  58. Schiex, T., Fargier, H., Verfaillie, G. (1995). Valued constraint satisfaction problems: hard and easy problems. In Proceedings of the 14th international conference on artificial intelligence (IJCAI’95) (Vol. 1, pp. 631–639). San Mateo: Morgan Kaufmann.

  59. Schulte, C., Lagerkvist, M.Z., Tack, G. (2006). Gecode: generic constraint development environment. In INFORMS annual meeting.

  60. Shapiro, L.G., & Haralick, R.M. (1981). Structural descriptions and inexact matching. IEEE Transactions on Pattern Analysis and Machine Intelligence, 3(5), 504–519.

    Article  Google Scholar 

  61. Shaw, P. (1998). Using constraint programming and local search methods to solve vehicle routing problems. In M.J. Maher, & J.F. Puget (Eds.) Proceedings of the 4th international conference on principles and practice of constraint programming (CP’98). lecture notes in computer science (Vol. 1520, pp. 417–431). Berlin: Springer.

  62. Shoham, Y., & Leyton-Brown, K. (2008). Multiagent systems: algorithmic, game-theoretic, and logical foundations. Cambridge: Cambridge University Press.

    Book  MATH  Google Scholar 

  63. Stuckey, P.J., & Tack, G. (2013). MiniZinc with functions. In C.P. Gomes, & M. Sellmann (Eds.) Proceedings of the 10th international conference on integration of artificial intelligence and operations research techniques in constraint programming (CPAIOR’13). Lecture Notes in Computer Science (Vol. 7874, pp. 268–283). Berlin: Springer.

  64. Stuckey, P.J, de la Banda, M.G., Maher, M., Marriott, K., Slaney, J., Somogyi, Z., Wallace, M., Walsh, T. (2005). The G12 project: mapping solver independent models to efficient solutions. In P. van Beek (Ed.) Proceedings of the 11th international conference on principles and practice of constraint programming (CP’05), Lecture Notes in Computer Science (Vol. 3709, pp. 13–16). Berlin: Springer.

  65. Stuckey, P.J., Feydy, T., Schutt, A., Tack, G., Fischer, J. (2014). The MiniZinc challenge 2008–2013. AI Magazine, 35(2), 55–60.

    Article  Google Scholar 

  66. van Hentenryck, P. (1999). The OPL optimization programming language. Cambridge: MIT Press.

    Google Scholar 

  67. van Hoeve, W.J. (2011). Over-constrained problems. In M. Milano, & P. van Hentenryck (Eds.) Hybrid optimization, optimization and its applications (Vol. 45, pp. 191–225). Berlin: Springer.

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Alexander Schiendorfer.

Additional information

Publisher’s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendix A: free objects in category theory: the free Monoid over a set

Appendix A: free objects in category theory: the free Monoid over a set

Mathematical categories are composed of objects (e.g,. algebraic structures) and morphisms (e.g., structure-preserving mappings) between them. Each morphism f admits a domain A and codomain B, both being objects, and is written as \(f : A \to B\). For all morphisms \(f : A \to B\) and \(g : B \to C\) there has to be a composite arrow (gf) : AC. Morphism composition \(\circ \) needs to be associative and for each object A, there has to be an identity morphism \(\text {id}_{{A}} : A \to A\) acting as “neutral element” with respect to composition, i.e., \(\text {id}_{{B}} \circ f = f \circ \text {id}_{{A}} = f\). The most straightforward example is given by the category \(\text {Set}\), where objects are sets, morphisms are functions, composition is function composition, and the identity morphisms are just the identity functions. A slightly more elaborate example is given by \(\text {PO}\), the category of partially-ordered sets, that has partial orders as objects and partial order homomorphisms (i.e., monotone functions) as morphisms. Note that this definition is proper since monotone functions are closed under function composition, i.e., if \(\varphi : |{P}| \to |{Q}|\) and \(\psi : |{Q}| \to |{R}|\) are monotone functions, so is \(\psi \circ \varphi \).

For our purposes, the true strength of category theory unveils when we consider transformations between different algebraic structures, e.g. between partial orders and PVS or between PVS and c-semirings. Such a mapping F between two categories \(\mathcal {C}\) and \(\mathcal {D}\) is called a functor. More precisely, F sends every \(\mathcal {C}\)-object A to a \(\mathcal {D}\)-object \(F(A)\) and every \(\mathcal {C}\)-morphism \(f : A \to B\) to a \(\mathcal {D}\)-morphism \(F(f) : F(A) \to F(B)\) (respecting identity, i.e., \(F(\text {id}_{{A}}) = \text {id}_{{F(A)}}\)). We have already seen an example, \(|{P}|\) that returns the underlying set of a partial order on objects and the underlying function of a monotone function (here, just itself) on morphisms. To see a more interesting example of functors that will provide intuition for Sections 3.3 and 3.4, consider the task of constructing a plain monoid (a set and one associative binary operation \(\cdot \) with neutral element \(\varepsilon \)) composed of elements taken from a set A. Our presentation closely follows [7, p. 20].

Example 4 (A monoid over a set)

Let \(A = \{a_{1}, a_{2}, \ldots \}\) be any set, called generators. We want to build a monoid \(\mathit {Mon}(A) = (X, {\cdot }, \varepsilon )\) composed of the elements in A. A is an object in the category \(\text {Set}\), \(\mathit {Mon}(A)\) is an object in the category \(\text {Mon}\). Assume that a function \(i_{A} : A \to X\) maps every \(a \in A\) to a different “new” element in our new underlying set X. For simplicity, we represent every \(a \in A\) by itself. Next, we add a dedicated neutral element \(\epsilon \) and define \(\epsilon \cdot x = x \cdot \epsilon = x\) for every \(x \in X\). Now, for every pair of generators a and b, we add a fresh element (denote it as \(a \cdot b\) which is distinct from any other element \(a^{\prime } \in A\)) and do so recursively for products of products etc. We only have to make sure to equate the elements that have to be equal by associativity, e.g., (ab) ⋅ c = a ⋅ (bc). This can be easily achieved if we represent every element “without parentheses”, leading to X being the set of words over A (i.e., \(A^{*}\) with \(\epsilon \) denoting the empty word) and \(\cdot \) being the concatenation (written as \(::\)). Now a functor \(\mathit {Mon} : \text {Set} \to \text {Mon}\) takes every set A to \((A^{*}, {::}, \epsilon )\) and every function (morphism in the category \(\text {Set}\)) \(f : A \to B\) to a monoid homomorphism \(\mathit {Mon}(f) : \mathit {Mon}(A) \to \mathit {Mon}(B)\) which is defined as follows: \(\mathit {Mon}(f) (\epsilon ) = \epsilon \), Mon(f)([a1,…, an]) = [f(a1),…, f(an)]. Elements of A are represented in \(A^{*}\) by \(i_{A}(a) = [a]\). Note that for any singleton list \([a] \in A^{*}\) iff aA.

With respect to Example 4, for constructing a monoid from a set, we could have also tried another functor \(N(A)\) that maps A to \((2^{A}, \cup , \emptyset )\) and represent aA as \(j_{A}(a) = \{a\}\). Clearly, \(N(A)\) also satisfies the monoid axioms of associativity and \(\emptyset \) being neutral. However, it is too specific: it assumes commutativity since \(j_{A}(a) \cdot j_{A}(b) = \{a\} \cup \{b\} = \{b\} \cup \{a\} = j_{A}(b) \cdot j_{A}(a)\). But we have already seen another monoid, \(\mathit {Mon}(A)\), where iA(a) ⋅ iA(b) = [ab]≠[ba] = iA(b) ⋅ iA(a). Hence, commutativity is not required for a monoid. Mapping A to \(N(A)\) would consequently unify elements that need not be equal. Once that mapping is done, it should be impossible to map “back” to a more general structure where the unified elements are distinct. Put differently, there do exist functions f from A to a monoid \(M^{\prime }\) that we cannot factorize as \({f}^{\sharp } \circ j_{A} = f\) for some \({f}^{\sharp }\).

Indeed, this is the case. Assume for a particular set \(\mathsf {A} = \{\mathsf {a}, \mathsf {b} \}\) that we have some function f into \(|{\mathit {Mon}(\mathsf {A})}|\), for instance f(a) = [aba] and \(f (\mathsf {b}) = [\mathsf {bab}]\). Now assume that we mapped \(\mathsf {A}\) to \(N(\mathsf {A})\) via \(j_{\mathsf {A}}\), having \(\mathsf {a}\) and b now represented as \(\{ \mathsf {a} \}\) and \(\{ \mathsf {b} \}\), respectively. Is there a way we can “still” reconstruct the function f, starting from \(N(A)\) and calling it \({f}^{\sharp }\)? To fulfill \(f = {f}^{\sharp } \circ j_{\mathsf {A}}\), we know that \({f}^{\sharp }(\{\mathsf {a}\}) = [\mathsf {aba}]\) and \({f}^{\sharp }(\{\mathsf {b}\}) = [\mathsf {bab}]\) must hold. But what about \({f}^{\sharp }(\{\mathsf {a},\mathsf {b}\})\)? To satisfy monoid homomorphism laws, \({f}^{\sharp }(\{\mathsf {a},\mathsf {b}\})\) must equal f({a}) :: f({b}) = [ababab]. But since \(\{\mathsf {a},\mathsf {b}\} = \{\mathsf {b},\mathsf {a}\}\), it must also hold that f({a, b}) = f({b, a}) = f({b}) :: f({a}) = [bababa]. Thus, no such function \({f}^{\sharp }\) can exist— \(N(\mathsf {A})\) is too specific.

Exchanging the rôles of \(N(\mathsf {A})\) and \(\mathit {Mon}(\mathsf {A})\) does not lead to the same problem. For any function f from a set A to the underlying set of any other monoid M, there indeed exists precisely one monoid homomorphism \({f}^{\sharp }\) that emulates f such that \(f = {f}^{\sharp } \circ i_{A}\), i.e., \(\forall a \in A : f(a) = {f}^{\sharp }(i_{A}(a))\) (see Fig. 8 or [7, p. 21] for a proof). This fact characterizes that \(\mathit {Mon}(A)\) is called the free monoid over A, being the most general monoid a set can be mapped to. Note that the existence of \({f}^{\sharp }\) corresponds to a “no confusion” argument since no elements are equated that should not be whereas the uniqueness of \({f}^{\sharp }\) relates to a “no junk” argument: If, for instance, we used \(\mathit {Mon}^{\prime }(A) = ((A \cup \{w\})^{*}, ::, \epsilon )\) with \(w \not \in A\), then we are free to chose the value of \(f^{\#}([w])\) (a “junk element”) as it is not constrained by the requirement \(f = {f}^{\sharp } \circ i_{A}\)—in contrast to all elements in A. Generalizing from this example, category theory allows to state this relationship between algebraic structures formally (see Definition 3 in Section 3.2).

Fig. 8
figure 8

A diagram of the free monoid over a set from Example 4. Mon(A) and N(A) refer to (A,::, 𝜖) and (2A,∪, ), respectively and M just refers to any monoid. The embeddings jA(a) = {a} and iA(a) = [a] are defined analogously for any set A. A dashed arrow indicates that, e.g., there is a unique monoid homomorphism f that makes the diagram commute, i.e., f = |f|∘ iA

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Schiendorfer, A., Knapp, A., Anders, G. et al. MiniBrass: Soft constraints for MiniZinc. Constraints 23, 403–450 (2018). https://doi.org/10.1007/s10601-018-9289-2

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10601-018-9289-2

Keywords

Navigation