-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* changed to L_int.md and implemented suggestions * add integer domain notebooks * add integer domains notebook and update file * Update letting_domain.md to fix L_int.md link --------- Co-authored-by: Özgür Akgün <ozgurakgun@gmail.com>
- Loading branch information
1 parent
4df549b
commit 7611e79
Showing
4 changed files
with
322 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# int | ||
|
||
Integer domains can be defined by | ||
``` | ||
int (<ranges list>) | ||
``` | ||
|
||
If no range is provided, then represents infinite domain of integers. | ||
|
||
An integer range is either a single integer | ||
``` | ||
int(n) | ||
``` | ||
|
||
or a list of sequential integers with a given lower and upper bound (inclusive). | ||
``` | ||
int(a..b, c..d, ...) | ||
``` | ||
|
||
Values must be between -2<sup>62</sup> + 1 and 2<sup>62</sup> - 1. | ||
|
||
See this demonstrated [here](https://github.com/conjure-cp/conjure/blob/main/docs/notebooks/IntegerDomains.ipynb). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,298 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"colab_type": "text", | ||
"id": "view-in-github" | ||
}, | ||
"source": [ | ||
"<a href=\"https://colab.research.google.com/github/conjure-cp/conjure/blob/main/docs/notebooks/IntegerDomains.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "-s7Zcn-_U6cb" | ||
}, | ||
"source": [ | ||
"## Integer Domains" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "MRiI4lvEVE0I", | ||
"outputId": "e1aa764c-b6b6-42cc-cd31-6e3f159d6b5b" | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Installing Conjure version v2.5.1 and Conjure Notebook version v0.0.10...\n", | ||
"Conjure is already installed.\n", | ||
"Conjure notebook is already installed.\n", | ||
"Conjure: The Automated Constraint Modelling Tool\n", | ||
"Release version 2.5.1\n", | ||
"Repository version a9cbc2e (2023-11-07 23:44:00 +0000)\n", | ||
"The conjure extension is already loaded. To reload it, use:\n", | ||
" %reload_ext conjure\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"!source <(curl -s https://raw.githubusercontent.com/conjure-cp/conjure-notebook/v0.0.10/scripts/install-colab.sh)\n", | ||
"%load_ext conjure" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "LPY0op8yXAMk" | ||
}, | ||
"source": [ | ||
"You can define integer domains in different ways." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "4vRxGMLYXjcO" | ||
}, | ||
"source": [ | ||
"For example, you can define integer domains as seen [here](https://github.com/conjure-cp/conjure/blob/main/docs/notebooks/letting_domain.ipynb)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "tPPGY5hOXuBm" | ||
}, | ||
"source": [ | ||
"Using a single integer:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 317 | ||
}, | ||
"id": "mjv1Gl-IU_84", | ||
"outputId": "7384d866-348e-42a3-ddb2-80619222a566" | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"```json\n", | ||
"{\"x\": 3}\n", | ||
"```" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"| Statistic | Value |\n", | ||
"|:-|-:|\n", | ||
"| SolverTotalTime | 0.005 |\n", | ||
"| SavileRowClauseOut | 0 |\n", | ||
"| SavileRowTotalTime | 0.067 |\n", | ||
"| SolverFailures | 1 |\n", | ||
"| SolverSatisfiable | 1 |\n", | ||
"| SavileRowTimeOut | 0 |\n", | ||
"| SolverTimeOut | 0 |\n", | ||
"| SolverNodes | 1 |\n" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"%%conjure --number-of-solutions=all\n", | ||
"find x: int(3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "R2LATZaEX3KY" | ||
}, | ||
"source": [ | ||
"By defining a lower and upper bound (inclusive)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 365 | ||
}, | ||
"id": "v2DmTqRSYDAg", | ||
"outputId": "4d640acc-8ca3-4fd7-b7f0-5868301d9b47" | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"## Solution 1" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"```json\n", | ||
"[{\"x\": 1}, {\"x\": 2}, {\"x\": 3}]\n", | ||
"```" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"| Statistic | Value |\n", | ||
"|:-|-:|\n", | ||
"| SolverTotalTime | 0.002 |\n", | ||
"| SavileRowClauseOut | 0 |\n", | ||
"| SavileRowTotalTime | 0.076 |\n", | ||
"| SolverFailures | 3 |\n", | ||
"| SolverSatisfiable | 1 |\n", | ||
"| SavileRowTimeOut | 0 |\n", | ||
"| SolverTimeOut | 0 |\n", | ||
"| SolverNodes | 3 |\n" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"%%conjure --number-of-solutions=all\n", | ||
"find x: int(1..3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "3jOSvw7FYP6E" | ||
}, | ||
"source": [ | ||
"Or, a list of integer ranges." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 365 | ||
}, | ||
"id": "oalwCZA8WSyJ", | ||
"outputId": "471e84a5-1245-421e-ec69-3a987f93656c" | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"## Solution 1" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"```json\n", | ||
"[{\"x\": 1}, {\"x\": 2}, {\"x\": 3}, {\"x\": 4}, {\"x\": 8}, {\"x\": 9}, {\"x\": 10}]\n", | ||
"```" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"| Statistic | Value |\n", | ||
"|:-|-:|\n", | ||
"| SolverTotalTime | 0.005 |\n", | ||
"| SavileRowClauseOut | 0 |\n", | ||
"| SavileRowTotalTime | 0.062 |\n", | ||
"| SolverFailures | 7 |\n", | ||
"| SolverSatisfiable | 1 |\n", | ||
"| SavileRowTimeOut | 0 |\n", | ||
"| SolverTimeOut | 0 |\n", | ||
"| SolverNodes | 7 |\n" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"%%conjure --number-of-solutions=all\n", | ||
"find x: int(1..3, 4, 8..10)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"colab": { | ||
"authorship_tag": "ABX9TyM6pbXXsB13v7hrNL5+/vY+", | ||
"include_colab_link": true, | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |