IjzerenHein / kiwi.js

Fast TypeScript implementation of the Cassowary constraint solving algorithm 🖖
Other
249 stars 24 forks source link

Integer Variables #20

Open james-bryce opened 4 years ago

james-bryce commented 4 years ago

Hello,

Is it possible to force variable values to be integers?

For example, I want the value to be either 0 or 1 (nothing in between).

Thanks!

IjzerenHein commented 4 years ago

Hi. No that's not possible. Why would you want this btw?

mreinstein commented 4 years ago

There are lotos of cases where this could be potentially useful. You're computing layout and want whole integer values for pixel coordinates, etc. Why is it impossible?

joshpoll commented 3 years ago

Linear programming with integer constraints is known as (mixed) integer linear programming (MILP or ILP). While linear programming problems can be solved in polynomial time, ILP is NP-complete. ILP solvers are based on linear programming solvers, but with significant added complexity. I think it's out of the scope of Kiwi (and other Cassowary solvers) to handle ILP.