diff --git a/README.md b/README.md index 2662d3d..1b89670 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ The examples are chosen to illustrate the benefits (and/or challenges) of queryi - [Birthday Money](Birthday%20Money.ipynb) - [Australian COVID vaccinations up-to-date and eligibility](COVID_vaccinations.ipynb) - [Australian COVID vaccinations mandatory for work roles](COVID_vaccinations_and_work.ipynb) +- [Eligibility for rates subsidy](eligible_for_rates_subsidy.ipynb) - [Range](Range.ipynb) ## Interactive Q&A with Rules as Code diff --git a/eligible_for_rates_subsidy.ipynb b/eligible_for_rates_subsidy.ipynb new file mode 100644 index 0000000..efb8ed0 --- /dev/null +++ b/eligible_for_rates_subsidy.ipynb @@ -0,0 +1,137 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "%reload_ext jetisu.query_idr_magic" + ] + }, + { + "cell_type": "markdown", + "source": [ + "# Eligibility for rates subsidy\n", + "\n", + "A person is eligible for a rates subsidy if, on the relevant date:\n", + "1. the person is a ratepayer; and\n", + "1. the property for which the rates are paid is a residential property; and\n", + "1. the property is the usual place of residence of the ratepayer.\n" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 18, + "outputs": [ + { + "data": { + "text/plain": "", + "text/markdown": "```\n\npredicate eligible_for_rates_subsidy(var bool: is_ratepayer,\n var bool: is_residential_property,\n var bool: usual_place_of_residence,\n var bool: is_retirement_subsidy,\n var bool: is_eligible) =\nlet {\n constraint is_eligible = (is_ratepayer /\\ is_residential_property /\\ usual_place_of_residence);\n constraint is_eligible -> not is_retirement_subsidy;\n }\nin true;\n```" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%%jetisu_show\n", + "eligible_for_rates_subsidy" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## I am a ratepayer, the property is residential and it is my usual place of residence. Am I eligible?" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 19, + "outputs": [ + { + "data": { + "text/plain": "", + "text/markdown": "|is_eligible|is_retirement_subsidy|\n|----|----|\n|True|False|" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%%jetisu_query\n", + "select is_eligible, is_retirement_subsidy\n", + " from eligible_for_rates_subsidy\n", + " where is_ratepayer and is_residential_property and usual_place_of_residence;" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## For the people who are eligible, what can we say about their status as a ratepayer, the kind of property under discussion and if they are resident at the property?" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 20, + "outputs": [ + { + "data": { + "text/plain": "", + "text/markdown": "|is_ratepayer|is_residential_property|usual_place_of_residence|\n|----|----|----|\n|True|True|True|" + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%%jetisu_query\n", + "select is_ratepayer,\n", + " is_residential_property,\n", + " usual_place_of_residence\n", + " from eligible_for_rates_subsidy\n", + " where is_eligible;" + ], + "metadata": { + "collapsed": false + } + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/jetisu/eligible_for_rates_subsidy.mzn b/jetisu/eligible_for_rates_subsidy.mzn new file mode 100644 index 0000000..86fe6c2 --- /dev/null +++ b/jetisu/eligible_for_rates_subsidy.mzn @@ -0,0 +1,10 @@ +predicate eligible_for_rates_subsidy(var bool: is_ratepayer, + var bool: is_residential_property, + var bool: usual_place_of_residence, + var bool: is_retirement_subsidy, + var bool: is_eligible) = +let { + constraint is_eligible = (is_ratepayer /\ is_residential_property /\ usual_place_of_residence); + constraint is_eligible -> not is_retirement_subsidy; + } +in true; \ No newline at end of file