aboutsummaryrefslogtreecommitdiff
path: root/box.mzn
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2024-01-22 10:23:58 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2024-01-22 10:23:58 +0000
commita79414bcf14d17c58e040a7b8524f7bd8f7e5e03 (patch)
tree4f2f232aca568711ecb35caa3444b54f4dfa4361 /box.mzn
Migrate from gists
Diffstat (limited to 'box.mzn')
-rw-r--r--box.mzn22
1 files changed, 22 insertions, 0 deletions
diff --git a/box.mzn b/box.mzn
new file mode 100644
index 0000000..0fd6f44
--- /dev/null
+++ b/box.mzn
@@ -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);