Multi-level inheritance of breeds

When thinking conceptually of Agent-Based Models, it is quite natural to think of types of agents as classes of objects, with subclasses for specialization.

NetLogo also supports this idea for one level of subclassing: turtles and named breeds.

But what if we have more than just one level of inheritance (subclassing)?

For example, in one of the models that I used in an introduction, I had a conceptual class hierarchy as follows:

                                       +--------------+
                                   +---|   factory    |
                   +---------+     |   +--------------+
               +---| company |<|---+
               |   +---------+     |   +--------------+
               |                   +---| distr-center |
+--------+     |                   |   +--------------+
| turtle |<|---+                   |
+--------+     |                   |   +--------------+
               |                   +---|    outlet    |
               |                       +--------------+
               |   +---------+
               +---|  truck  |<|--- (more subclasses)
                   +---------+

Then, we can either create breeds at the first level for companies and trucks,
or at the second level for factories, distr-centers, outlets, and subclasses of trucks
(or use different levels in different branches), but not both.
Both choices have their own complications.

Now, it would be nice if we could declare them all as breeds with the proper “is-a” relation.
My proposal is adding a breeded breed primitive:

We could do something similar for link breeds:

Once this mechanism is in place, there is no limit to the levels of subclassing.
We can declare -owns at each level, and have procedures specific for any breed – as shown in its tagging comment.
(For “breeded reporters” we would need another mechanism. A module mechanism might help here.)

Hi Mark,

This is a fantastic idea, and one that has been floated around in the past. The primary reason why it has yet to be implemented in NetLogo is due to the added complexity of comprehending inheritance. You mentioned that it is “quite natural” to think of agents as classes of objects with specializing subclasses, but this seems like a very computer science-y thought process to me. For the majority of NetLogo users, who will likely not approach the language in this way, gaining a conceptual understanding of inheritance as well as all the technical implications of it could be quite difficult. So we hesitate to add something like this to the language that may not benefit the majority of users and would make it more difficult both to learn the basic structure of the language and to read and interpret existing models.

That said, it could be beneficial for more advanced users to have access to this kind of functionality. There is a non-zero chance that in a future version of NetLogo there may be some sort of framework for creating parser extensions or custom variants of the language, for which this idea would be a perfect candidate. We’ll definitely keep it in mind if that does end up happening!

Isaac B.

Hi Isaac,

Good to hear that this idea has been around already.
As my examples show, the overhead can be minimal.

Full Object-Orientation (OO) is quite another thing. And there I agree that it is “computer science-y”.
I would not want to introduce full OO into NetLogo. As I said, the quick start in NetLogo is a very strong point.

The idea of subclasses and “is-a” relations is actually quite natural to non computer scientists as well. In my experience teaching to (mainly) students in other disciplines, they grasp that idea easily. In fact, the idea stems from Biology.

The difficult part of OO in my experience is that operations and data are kept together, and especially that you can’t have operations apart from data.
(This is where Python is so easy in that it allows both. Under the hood everything is Object-Oriented…)

So, please keep this idea of “breeded breeds” on the list of options.