Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added early draft of labor model example. #36

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

ohaaga
Copy link
Contributor

@ohaaga ohaaga commented Aug 8, 2024

Any and all comments welcome.

@kris-brown kris-brown added the documentation Improvements or additions to documentation label Aug 22, 2024
@kris-brown kris-brown self-requested a review August 22, 2024 16:25
Copy link
Collaborator

@kris-brown kris-brown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I haven't gotten to the rules part, but here are some initial thoughts on the beginning!

docs/literate/labor_model.jl Outdated Show resolved Hide resolved
docs/literate/labor_model.jl Show resolved Hide resolved
docs/literate/labor_model.jl Outdated Show resolved Hide resolved
docs/literate/labor_model.jl Outdated Show resolved Hide resolved
docs/literate/labor_model.jl Outdated Show resolved Hide resolved
docs/literate/labor_model.jl Outdated Show resolved Hide resolved
docs/literate/labor_model.jl Outdated Show resolved Hide resolved
docs/literate/labor_model.jl Show resolved Hide resolved
docs/literate/labor_model.jl Show resolved Hide resolved
# change which can occur in our model. These will take the form of ACSet rewriting rules,
# which are a generalization of graph rewriting rules (since a graph can be defined as a
# relatively simple ACSet, or indeed CSet). We will use Double Pushout and Single Pushout
# rewriting, which both take an input pattern of the form L <- I -> R, where L is the input
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think inline LaTeX will be good here for things like $L \leftarrowtail I \rightarrow R$

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little better now? Didn't go full LaTeX.

# pattern to be matched in the existing state of the world ("Before"), R is the output
# pattern that should exist going forward ("After") and I is the pattern of items in the
# input match which should carry over into the output match.
#
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere between this first and second paragraph of this section, you should introduce the concept (perhaps even at just an intuitive level) of what an "ACSet Transformation" is, since if I'm not mistaken I don't see it introduced anywhere else but it gets highly used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a line. May want to discuss audience expectations in a larger sense.

death_abm_rule = ABMRule(:Death, death, ContinuousHazard(1));

people_only_abm = ABM([birth_abm_rule, death_abm_rule]);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to show a plot here of the population just to make this point before going to the more complicated ABM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great minds think alike. I'll add it back in once we have SPO.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up I don't see this added back in!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some graphs of the people only ABM (with and without firms).

# in the labour market using this "market tightness" ratio.

function market_tightness(state_of_world::LaborMarket)
length(state_of_world.parts.Vacancy)/number_unemployed(state_of_world)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use nparts(state_of_world, :Vacancy)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

# ## Background
# Inspired by the search-and-matching ABM implementation in [del Rio-Chanona et. al. (2022)](https://royalsocietypublishing.org/doi/suppl/10.1098/rsif.2020.0898),
# we demonstrate a very basic ABM of a [labor market seach-and-matching model](https://en.wikipedia.org/wiki/Search_and_matching_theory_(economics)).
# A state-of-the-world in our model will be represented by an ACSet on a schema that we define, and the model itself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "state of the world" (in quotes) rather than with dashes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

# Since the ACSet rewrite rules are defined using ACSet instances and the homomorphisms (or ACSet Transformations) between
# them, it will be useful to revise [Catlab.jl](https://github.com/AlgebraicJulia/Catlab.jl) and
# [AlgebraicRewriting.jl](https://github.com/AlgebraicJulia/AlgebraicRewriting.jl) functions for creating them.
# In practice, the rules below are defined using identitiy morphisms on coproducts of representables and homomorphism search for unique homomorphisms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"identitiy"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

# Since the ACSet rewrite rules are defined using ACSet instances and the homomorphisms (or ACSet Transformations) between
# them, it will be useful to revise [Catlab.jl](https://github.com/AlgebraicJulia/Catlab.jl) and
# [AlgebraicRewriting.jl](https://github.com/AlgebraicJulia/AlgebraicRewriting.jl) functions for creating them.
# In practice, the rules below are defined using identitiy morphisms on coproducts of representables and homomorphism search for unique homomorphisms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a bit much to throw technical terms like "coproducts of representables" and "homomorphism search" at them without context in the "Background" section (at least with ACSets you have a link to the Github which has a public-friendly README, but even with that I wouldn't count on people clicking the link ... rather they might just end up confused / thinking this post isn't for them).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Killed that sentence.

# between them.
#
# ## Schema
# We define our Schema "from scratch" by specifying the types of objects in our model and the mappings
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm this post doesn't talk about any other ways to define a schema so "from scratch" might not make sense (not clear what you're contrasting it with) - I think what you wrote makes sense without that qualifier.

#
# ## Schema
# We define our Schema "from scratch" by specifying the types of objects in our model and the mappings
# (or "homomorphisms") between them.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if 'mapping' or 'homomorphism' is the right term to use here (of course, they're both unambiguously fine to use among people who know what they're talking about!). To see my worry: if you ctrl+f "mapping" or "homomorphism" in the rest of the blog post, it gets used exclusively to mean C-Set homomorphism, which is very different from an arrow in the schema. Maybe when introducing it you could say that declaring a schema is declaring the types of objects/entities (denoted by Ob in the code below) and the functional relationships between them (denoted by Hom). There's a risk someone becomes confused ("why is it called Hom?") but I worry about the other kind of confusion more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave it a try.

# functions. As an alternative, we can specify some basic elements of our instances by
# taking the freely constucted minimal example of each of our entities ("objects" - but
# not in the sense of Object-Oriented Programming). This creates a "generic" instance
# of the chosen entity, which in particular doesn't force any two objects to be the same
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a different use of 'object' than the sentence which immediately precedes it (the free instance does not force any two parts to be the same ... e.g. E and V are objects in SchGraph but V#1 and V#2 of a particular graph are parts). I don't know if anyone who hasn't worked a lot with ACSets before will quite understand this sentence anyways (saying that it's generic might be enough to communicate to readers what a representable is, and the examples to follow will solidify their intuition).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing to "parts" - would you recommend dropping that clause entirely? I don't know that "freely constructed" will convey that fully to users.

death_abm_rule = ABMRule(:Death, death, ContinuousHazard(1));

people_only_abm = ABM([birth_abm_rule, death_abm_rule]);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up I don't see this added back in!

id(P⊕F)
);

# We assume at first that hiring and firing occur at constant rates.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a semicolon here in order to prevent it from printing out an ABM (which looks massive/ugly because we don't pretty print that data structure)

end
) |> ClosureState;

full_abm = @pipe constant_job_dynamics_abm |>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semicolon again

) # hide
end # hide

plot_beveridge_curve(result) # hide
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain very briefly (provide a link) what Beveridge is?

Also a concluding sentence would be nice so that the piece doesn't abruptly end!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the figure has a legend with "y1" as the name of the line - maybe you can rename it or remove the legend?
Screenshot 2024-10-24 at 5 52 17 PM

…wing an error with the versions of other libraries that I'm using.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants