
Ask HN: How best to model a government programmatically? - nstj
So I&#x27;ve been looking lately at the functioning of government and how it&#x27;s basically just a bunch of rules (laws) with some state (time, elected officials, votes).  I&#x27;m wondering if there&#x27;s precedent for modelling systems like this programmatically?<p>For an example of the desired functionality, let&#x27;s say you&#x27;re an interested citizen who wishes to gain more insight into a proposed law - the model I&#x27;m talking about would take the current state of your government and provide you with the possibilities for that law to pass.<p>I understand this is a difficult problem and involves a fair bit of ambiguity (indeed there would be many outcomes from a model which would be &#x27;let the courts decide&#x27;) but as a starting point I&#x27;m interested in what people might suggest could be an interesting place to start;  Prolog?  Smart contracts?<p>Much obliged for any insight.
======
randcraw
I've long thought 'government' was a fascinating topic for computers to
tackle, but first I think you need to answer what it is you want to model: 1)
the process of government (politicians and politics) or 2) the outcome of
government -- the regulation of business and civil activity and international
concordances.

I think the US gov't (and many military contractors) have long attempted
option 1. The modeling of adversary nations or individuals and anticipation of
their behavior using scenarios and war games has been around long before
computers. But the number of unknown variables and the unknown state of those
that _are_ known has greatly limited the practical value of such efforts,
IMHO. Even predicting the binary outcome of presidential elections has shown
the weaknesses inherent in endeavors like this.

But how about option 2; could you model the analytical and decision processes
that regulate a society toward 'homeostasis'? Probably, though I suspect
adjusting the weights to wisely balance the interests, values, and civil
rights in corporations, persons, and countries is likely to prove tricky. But
could a lot of government's existing processes be effectively modeled by
computer or even automated? Absolutely yes, IMHO.

~~~
nstj
1) was definitely the one I was going for - essentially in a bid to show how
certain outcomes can / can't occur given the current state and laws of a
government.

ie: if you want to pass a tax cut, you need to do x, y and z, though this is
dependent on the current state of the budget, etc etc (this is actually
happening now in US Congress).

------
vkrm
You could look at Democracy 3 [0] for inspiration, its a game that tries to
model a democratic country from the point of view of a candidate.

[0] [http://positech.co.uk/democracy3/](http://positech.co.uk/democracy3/)

~~~
RugnirViking
The issue here is that in that game the player is a despot, passing laws with
no oversight and no voting

------
jwdunne
I've thought about this one for a while and I keep coming back to modelling
actors with a set of behaviours that influences/triggers other behaviours and
variable changes (which can then influence other behaviours and variables).

This way a government becomes a set of actors whose behaviours include
creation of policy, of which are intended to influence the behaviours of all
actors in the governing nation, another set of actors of which the serving
government is a proper subset.

Much like democracy 3, recommended below, it'd form one or more graphs,
depending on how far one takes it.

My main idea was to simulate an economy independent of current economic models
but then simulating government is an integral part of that project.

~~~
nstj
Great call, and I'm checking out Democracy now. At its heart, I'm attempting
to reason about modelling a set of defined laws in some kind of programmatic
model (ie: if it was the US, it would be 'a bill needs 217 votes in the House
and 51 votes in the Senate, unless it's eligible for filibuster, where it then
needs 60 votes, etc etc). Appreciate your thoughtful feedback.

------
chubs
The law comes about from many years of precedent based on various ambiguous
circumstances, eg it's a bit of a 'bottom up' thing, i'm not sure if a 'top
down' approach like this would work for day-to-day laws. Maybe it'd be better
for things that don't change much, eg a constitution. Fun thought experiment
though!

------
rnabel
Very broad question but related: this blog [0] discusses how a modelling
product was used to simulate the internet backbone. If your aim is real-time
reaction modelling of actors, this could theoretically be implemented using
such a system.

They have an open beta [1], although building a comprehensive system like that
described above seems a very significant task even to a large engineering
team.

[0] [https://improbable.io/2016/03/24/what-we-found-when-we-
simul...](https://improbable.io/2016/03/24/what-we-found-when-we-simulated-
the-backbone-of-the-entire-internet-on-spatialos)

[1] [https://spatialos.improbable.io/get-
spatialos](https://spatialos.improbable.io/get-spatialos)

(Disclaimer: I have interviewed with and accepted an offer by Improbable)

~~~
nstj
this is great - and I am actually a customer of Telstra and experienced the
outage they describe in the article!

------
joeclark77
I cannot recommend enough a paper called "A Garbage Can Model of
Organizational Choice" (1972) by Cohen, March, and Olsen. Maybe the best thing
I was assigned to read during my whole PhD. The authors propose that decisions
are made by random co-occurrences of problems looking for solutions, solutions
looking for problems, and people looking for opportunities to make decisions
(not exactly in those terms). The authors even did a little computer
simulation, which might prove enlightening (or distressing) given your
objective. Link:
[http://www.jstor.org/stable/2392088](http://www.jstor.org/stable/2392088)

Thanks for reminding me of this.

------
shabinesh
This is interesting to me. I am thinking loud here. The first thing for me
would be to understand from a top level the different departments/ministries
have a set of function and they are required to communicate between them to
accomplish certain task. So before I could make anything programmatically I
could at some level try to model it mathematically. I believe these are
processes which ought to communicate, could we think of these as modeled by
pi-calculus
([https://en.wikipedia.org/wiki/%CE%A0-calculus](https://en.wikipedia.org/wiki/%CE%A0-calculus))

I am not sure I am even close enough to what your are asking, but thats my two
cents.

~~~
nstj
this is exactly the kind of thing I'm going for - effectively modelling the
legal relationship between different areas of government and how they achieve
intended goals / the permitted ways to achieve outcomes. I'll check out pi-
calculus now.

------
grizzles
Your question is too general, and you'd have realized it if you built a toy
model. You need to think about what your goals are with the model. If it's to
build a replica government in code, then make a start and have at it, no
special tech is needed. Just start encoding your data (eg. {"Jaywalking Fee" :
"100.00"} into files your model can parse.

Prolog isn't the right tool here, there are no complex dependency chains to
reason through, it's not really right for modelling uncertainty, which you
will have to accept until you start caring about what parts of the model will
need to be high fidelity.

------
glbl
It's impossible to program what is inherently broken unless of course your
software was full of glitches and had as many bugs in it as our governments.
You can of course debug, but the glitches are impossible to predict, and thus
program.

If you were to remove all elected officials from the equation, then
programming becomes a much more straightforward task and could be done
following due process. In an ideal world passing laws/policies would be a
matter of logic, where the benefit of citizens and planet are the primary
objectives. However, given the interests and persuasions of individual
players, and the influences of third parties, even the deepest of phycological
and analytical appraisal tools would come up short when trying to predict the
decisions of any given policymaker.

Maybe that's the way to tackle this, remove the protagonists and concentrate
on the system. Once you have a schema of the system, you could attempt to
integrate the variables. Good luck with the latter.

IMO, I would start again. Determine where the power is now, and think about
where it should be. How the decisions are made now and how they could be made
better with your system.

You may already know about it but if not, this might give you some
inspiration:
[https://www.globalchallenges.org/en](https://www.globalchallenges.org/en)

In essence, there is a 5m prize pool for someone/team to come up with a UN
2.0. One that works. That would entail fixing governments for any kind of UN
to work effectively.

~~~
nstj
So this is moreso codifying the current rules and regulations of our existing
government - and the whole point is to _show_ the loopholes and issues with
current laws. To start with you could just codify the Constitution and work
out from there. So to extend - how would you programmatically model the
Constitution? :)

------
LarryMade2
Government is a set of laws federal, state and local, nothing is the same.
Also a policy is local to the area.

When you get into information that also varies, for one reason or another
governments use different systems computer and otherwise. A lot of government
collaboration is working out how these similar but dissimilar systems will
operate. What works for say Los Angeles certainly doesn't work for San Andreas
and visa versa, and it gets even weirder if you cross state lines.

A respectable goal is to work up universal data interchange standards, not set
systems, but say a "record" of a law should contain minimally certain
information in certain text standards, etc. This leaves the municipalities to
still work with their preferred systems but when doing cross-government
business everyone know what data to expect minimally.

The downside of this is sometimes some entities are bad players and vote for
bad data rules (i.e. the ever dwindling census detail) which benefit them in
one way or another.

------
this-that
Could this be related?

System Dynamics

[https://en.m.wikipedia.org/wiki/System_dynamics](https://en.m.wikipedia.org/wiki/System_dynamics)

~~~
ljw1001
I was going to suggest system dynamics as it especially well suited for
complex domains, and for simulating the results of policy changes.

Tools like Vensim and IThink are currently (commercially) available, and there
are some open source tools that can do this. I think Berkeley Madonna is one,
but I'm not entirely sure.

------
StephenOTT
Are you looking to model the System and its projected and/or perceived
outcomes (such as using the field of Systems Theory)? or looking at how those
laws/rules/policies are implemented in the bureaucracy?

If you have a proposed law, the law is generally (or at least supposed to be)
a framework, and the bureaucracy chooses how to interpret and implement that
framework.

If you want to model the bureaucracy (its inputs, outputs, efficiency, etc),
take a look at BPM tools like Camunda, or JBOSS. Have done some of this
related to local governments ([https://github.com/StephenOTT/Gov-BPMN-Sub-
Process-Departmen...](https://github.com/StephenOTT/Gov-BPMN-Sub-Process-
Departmental-Ownership)).

If you want to model the System (a modelled version of the impacts of the laws
and how they could impact the other parts of 'society'), then take a look at
Systems Theory and related apps. Mesa looks like a good starter tool for this.

------
McHawkeye
I've been thinking about literate programming for government policy / laws.
Composing law documents using python notebook/R markdown. This could allow
citizen's to more easily draft, assess or monitor new laws. Or build services
around the 'API' of the law. Having the wording and entities semantically
defined in code would probably help move towards modelling you are interested
in. Here's my blog about it [http://fozy81.github.io/2016/02/25/r-markdown-
for-policy-doc...](http://fozy81.github.io/2016/02/25/r-markdown-for-policy-
documents.html)

------
Someone
There are macro-economic models
([https://en.wikipedia.org/wiki/Macroeconomic_model](https://en.wikipedia.org/wiki/Macroeconomic_model))
that include such things as taxation structure, effect of child benefits on
how long parents work, effect of taxation on consumption, effect of
export/import restrictions, etc.

AFAIK, some of those models are fairly accurate, but not at the level that
physics models are. They also do not include all quantities citizens are
interested in, such as pollution levels or effects on commute times, and even
if they do, they likely don't do it at small scales (a model may predict that
commute times will go down on average if policy P is enacted, but that may not
be uniformly across the country)

------
hl5
Conway's game of life

[https://en.m.wikipedia.org/wiki/Conway%27s_Game_of_Life#](https://en.m.wikipedia.org/wiki/Conway%27s_Game_of_Life#)

------
chid
I'm curious what people here think of Agent Based Modelling.

~~~
neilwilson
Definitely the way to go. Currently looking at Mesa
([https://github.com/projectmesa/mesa/](https://github.com/projectmesa/mesa/))
as a way of modelling an economy (which will include government as an actor -
and a form of every other main actor as well).

I've got a project open here:
[https://github.com/NeilW/maytrix](https://github.com/NeilW/maytrix) which
sort of gives an indication of where I'd like to go.

Open to any and all collaborations to get it moving.

~~~
nstj
NICE

------
lioeters
Perhaps one can start by building a "SimGovernment", a simulation with the
major features/structures representing those in real life.

------
m0llusk
Governments operate and constrain social systems, so to simulate government it
would be necessary to simulate social systems.

------
StephenOTT
Are you l

