diff options
author | Nat Lasseter <nat.lasseter@york.ac.uk> | 2024-01-22 10:23:58 +0000 |
---|---|---|
committer | Nat Lasseter <nat.lasseter@york.ac.uk> | 2024-01-22 10:23:58 +0000 |
commit | a79414bcf14d17c58e040a7b8524f7bd8f7e5e03 (patch) | |
tree | 4f2f232aca568711ecb35caa3444b54f4dfa4361 /box.mzn |
Migrate from gists
Diffstat (limited to 'box.mzn')
-rw-r--r-- | box.mzn | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +include "globals.mzn"; + +% Given an integer n and a real e +par int: n = 566*708; +par float: e = 16/9; + +% Find two integers r <= c +var int: r; var int: c; +constraint c >= r; +output [ + "Rows: ", show(r), "\n", + "Columns: ", show(c), "\n" +]; + +% Such that (r-1)c < n <= rc +constraint + ((r-1)*c) < n + /\ + n <= (r*c); + +% And the ratio c/r is as close to e as possible. +solve minimize abs(c/r - e); |