Hacker News new | past | comments | ask | show | jobs | submit login
A Short Intro to Constraints (zalo.github.io)
185 points by nkoren 63 days ago | hide | past | web | favorite | 18 comments



I'm curious if someone would know where to point me?

There's many problems I would like to solve using some sort of model definition with constraints given, and variable(s) to optimize. Either to aid in guiding the design of a system, or using generative design.

Example:

    - Electrical power, voltage and amperage constraints along with physical size constraints, in a circuit model.
    - Data size and throughput and concurrency constraints in a distributed system models.
I have a feeling there must be well known techniques and/or tools to do these kind of general purpose constraint modelling, but I can't put my finger on it. The closest that comes to mind is using Prolog, but I've only used it with boolean type of constraints.


What you describe falls under the general umbrella term of combinatorial optimization, of which Constraint Programming, Mixed Integer Programming, SAT, SMT, and local search techniques can be said to fall under.

Personally, I find the languages and methods used in constraint programming (CP) to define models the most clear, even though that is not always the best way to actaully solve the problems.

To write CP models, the MiniZinc language is quite nice and has support for using many different solvers on the back end. The MiniZinc website (https://www.minizinc.org/) has quite a lot of documentation. For an outsider perspective, Hillel Wayne wrote an interesting blog post on using MiniZinc (https://hillelwayne.com/post/minizinc/).


check out “SAT/SMT by Example”, which is a perennial HN favorite, for good reason. it mainly uses Z3.

this is only one of many options but it’s a good one.


Have you looked at Propagator Networks? It's a fascinating computation model that I believe was originally proposed by Gerald Sussman. The original use case/example was electrical circuits.


Seems like AYBABTME is talking about constrained optimization, whereas you are speaking of "constraints" in a different context, i.e., this paper (https://dspace.mit.edu/handle/1721.1/6255) by Stallman and Sussman, further developed in Guy Steele's PhD dissertation, eventually leading to the propagator model by Radul and Sussman (https://groups.csail.mit.edu/mac/users/gjs/propagators/). Both kinds of "constraints" are very interesting, but one is a class of numerical algorithms and another a general programming framework.


Yup, it looks like I glossed over the optimization part and latched onto the circuits part.


google or-tools

minizinc

prolog clpfd, chr

eclipse prolog-like constraint system

answer set programming


Yeah, Gecode supports floating point variables if that's of interest.


In the distance constraint, won’t the point always land _on_ the circle? The visualisation shows that it can be inside the circle too.


So probably the author put a "distance less than or equal to" constraint. Having a "distance equal to" constraint would have the point always on the circle. And, magically, "distance larger than" would have the point always outside the circle.


That one didn't show code. I have to assume the code tests if the point is outside the circle before constraining it, similarly to how a later constraint tests if a point is inside the circle before constraining it (the one where you shove balls around).


Any idea how the graphics gets rendered on the brower here? Is there a javascript library for this?

I see further interesting graphics from the author here: https://github.com/zalo/MathUtilities


The first post is done in Paper.js, while the rest of them are done in Three.js. The scripts in MathUtilities are for the Unity3D game engine.

All of them are excellent graphics frameworks (though with strengths in 2D, 3D, and standalone content respectively).


The canvas has a mousemove handler that points to http://paperjs.org/


Truly didactic while being entertaining. Playing lets the concept sink in better.


This is a similar project that showed up on hn a while ago:

http://omrelli.ug/g9/gallery/


I could see this as a great as visualization tool for a high school geometry class, i.e. explaining solutions for systems of inequalities.


there are not so many videos about this topic

this GDC talk is kinda hard to understand (at least for me) https://www.youtube.com/watch?v=SHinxAhv1ZE




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: