We are delighted to have Luis R Izquierdo as a guest blogger today. Luis is a complex systems modeler with a strong background in economics, computer simulation and mathematics. His main area of expertise is game theory and the analysis of complex systems. Luis is currently lecturing Economics, Finance, Machine Learning, Complex Systems Modeling and Statistics at the University of Burgos (Spain).
Computational modeling is particularly useful to formalize models and hypotheses written in natural language. Indeed, computers can only deal with formal languages, so if we want to implement a computer model we must get rid of any imprecision, ambiguity, incompleteness and inconsistency in our description. This is one of the reasons why the mere effort of trying to translate a model expressed in natural language into computer code can be a very fruitful exercise in itself.
Models expressed in natural language often contain imprecise concepts (such as “wealthy” or “poor”) and fuzzy logic is a discipline that can assist us in formalizing them. Concepts such as “wealthy” are imprecise because we do not find it natural to assert that any given person is definitely either “wealthy” or “not wealthy”, i.e. we do not feel comfortable dividing the whole population into two sets such that everyone in one set is definitely wealthy whilst everyone in the other set is definitely not wealthy. Instead, we seem to be more comfortable conceding that propositions of the type “Person x is wealthy” may be true to some extent, i.e. they may have a truth value that lies somewhere in between the two absolute extremes true and false. Allowing for more than two truth values (besides the traditional true and false) takes us to the realm of many-valued logics, of which a particularly relevant instance for computer modeling is fuzzy logic.
In fuzzy logic, imprecise concepts are formalized using fuzzy sets. Fuzzy sets are an extension of classical sets in the sense that –besides full membership and full non-membership– fuzzy sets allow for partial membership. In this way, an element may belong to a certain fuzzy set, it may not belong…, or it may belong to some extent. The degree to which a particular element belongs to a fuzzy set ranges from 0 (full non-membership) to 1 (full membership). Thus, graded concepts such as “wealthy” can be naturally modelled as fuzzy sets, with individual people belonging to the set “wealthy” to a greater or a lesser degree (which can be interpreted as the truth value of the proposition “Person x is wealthy”).
Sometimes the degree of membership of an element in a fuzzy set depends only on a certain property of the element. For instance, it seems natural that the degree of membership of any person in the set “wealthy” (i.e. the extent to which the person is wealthy) depends only on the monetary value of the person’s possessions. A possible way of formalizing the concept “wealthy” as a fuzzy set is sketched below.
The membership function of the fuzzy set “wealthy” drawn above would assign a degree of membership 0.2 to every person whose possessions are worth $1000 and a degree of membership 0.85 to every person whose possessions are worth $200 000. Equivalently, this definition of “wealthy” would assign a truth value 0.2 to the proposition “A person whose possessions are worth $1000 is wealthy”. Naturally, this is just one possible way of formalizing the concept “wealthy” made up for this post (and I purposefully didn’t specify which dollar I am using), so please do not read anything else into it! 😀
The logical connectives AND and OR can be modeled in fuzzy logic with various functions, but the most commonly used are the minimum (min) and the maximum (max) respectively. As an example, let us compute the degree to which a certain person x is “Tall AND middle-aged”, assuming the assigned truth value to the proposition “x is Tall” is 0.8 and the assigned truth value to the proposition “x is Middle-aged” is 0.4.
TruthValue(x is Tall AND x is Middle-aged) =
= min(TruthValue(x is Tall), TruthValue(x is Middle-aged)) = min(0.8, 0.4) = 0.4
TruthValue(x is Tall OR x is Middle-aged) =
= max(TruthValue(x is Tall), TruthValue(x is Middle-aged)) = max(0.8, 0.4) = 0.8
There are also methods to deal with fuzzy “IF-THEN” rules, i.e. rules whose antecedents and consequents may contain fuzzy concepts. A nice example is provided here, where the authors use fuzzy logic to compute a numeric tip given the following rules:
- IF service is poor or the food is rancid, THEN tip is cheap
- IF service is good, THEN tip is average
- IF service is excellent or food is delicious, THEN tip is generous
Recently we have released a well-documented library of functions that facilitates the use of fuzzy logic within NetLogo. Using these functions, it becomes simple to implement agent-based models where individual agents hold their own fuzzy sets (representing subjective imprecise concepts) and follow fuzzy rules which may affect the way agents behave and interact. As an example of a potentially useful application, our library makes it particularly easy to analyse the robustness of a certain theory expressed in natural language to different specifications of the imprecise concepts that the theory contains (which may be represented with different fuzzy sets). Also, it facilitates the exploration of the effect that heterogeneity in concept interpretations may have in a society (i.e. the significance of the fact that different people may have different interpretations of the same concept).
Obviously, neither fuzzy logic nor our library are strictly necessary to build models with agents holding different instances of imprecise concepts, but the work we have developed helps implement such models in a natural and transparent way. Thus, we hope that the NetLogo fuzzy logic library will make the endeavour of translating theories expressed in natural language into computer programs both easier and more rigorous at the same time.
Featured image: Agents with heights drawn from a normal distribution, shaded light-to-dark based on membership in a logistic fuzzy set for “tall”.