lunes, 10 de febrero de 2014

Flocking análogo y digital

Bandada análoga y digital

El video muestra a estorninos (miles de ellos) haciendo una coordinación colectiva de vuelo sorprendente llamada bandada o flocking. Es un proceso que fácilmente puede advertirse como uno de conductas individuales simples que deriva en conducta agregada compleja. Un modelo ABM clásico.

Abajo se aprecia, en inglés, un modelo de flocking clásico hecho en Netlogo. ¿Que tan difícil es lograr el modelo real en el simulado? ¿Qué opinan?

domingo, 4 de agosto de 2013

Manual de Netlogo: Introducción, escenario y algunas vistas iniciales


Manual de Netlogo en español


He preparado un manual de Netlogo en español que te permitirá familiarizarte con este lenguaje de programación de una forma muy sencilla, a través de pequeños programas-ejemplo.


¿Qué es Netlogo? ¿Dónde puedo obtener el programa?


Netlogo es un entorno de programación que permite la simulación de fenómenos naturales y sociales. Fue creado por Uri Wilensky en 1999 y está en continuo desarrollo por el Center for Connected Learning and Computer-Based Modeling.

Netlogo es particularmente útil para modelar sistemas complejos que evolucionan en el tiempo. Los implementadores de modelos pueden dar instrucciones a cientos o miles de agentes para que todos ellos operen de manera independiente, entre sí y con el entorno. Esto hace posible explorar la relación entre el comportamiento a bajo nivel de los individuos y los patrones macroscópicos que surgen a partir de la interacción de muchos individuos entre sí.

Netlogo permite a los usuarios abrir simulaciones y “jugar” con ellas, así como explorar su comportamiento bajo una serie de condiciones. Asimismo, permite al usuario la creación de sus propios modelos. Netlogo es lo suficientemente sencillo como para que los estudiantes y los profesores puedan ejecutar las simulaciones o incluso construir las suyas propias. Además, su grado de desarrollo actual es suficiente como para servir como una herramienta potente para investigadores en muchos ámbitos.

Existe abundante documentación y tutoriales sobre Netlogo. El programa incluye una galería de modelos (models library), que contiene una amplia colección de simulaciones que pueden ser ejecutadas y modificadas. Este conjunto de modelos pertenece a ámbitos muy diversos, tanto de la naturaleza como de ciencias sociales (biología, medicina, física y química, matemáticas y computación, economía y psicología social).

Existen dos maneras de ejecutar Netlogo:

1. Descargando e instalando el programa (permite simular y editar modelos, así como la creación de modelos propios).
2. Ejecutar un applet desde una página web (permite la ejecución de los modelos, pero no editarlos ni crear modelos nuevos).

El programa puede descargarse de manera gratuita desde aquí. Para su funcionamiento, requiere tener instalada en el ordenador una máquina virtual de Java (JVM - Java Virtual Machine) versión 1.4.2 o superior. En la versión de descarga para Windows existe la opción de descargar una versión que incluye la JVM necesaria.


Introducción al escenario de simulación de Netlogo


Netlogo es un lenguaje de programación que sigue la filosofía del modelado basado en agentes.

Concretamente, en Netlogo existen 3 tipos de agentes:
- Turtles (tortugas).
- Patches (celdas).
- Links (relaciones entre tortugas).
- Observer (observador).






Las tortugas son los agentes que se mueven por el mundo. Interaccionan entre sí y con el medio. Cada tortuga viene identificada por un identificador que es único para cada tortuga.

Netlogo denomina “mundo” (world) al terreno en el que se mueven las tortugas. Cada porción cuadrada de mundo se denomina patch. Cada patch está identificado por las coordenadas de su punto central.

Las tortugas se mueven por el mundo (y, por tanto, por encima de los patches). Las tortugas interaccionan entre sí según unas reglas de comportamiento y con el medio (es decir, con los patches).

Se pueden modelar la relación entre distintas tortugas mediante links, que es el tercer tipo de agente presente en Netlogo. Los links se designan mediante un par (tortuga1, tortuga2), que indica las dos tortugas relacionadas mediante dicho link.

Finalmente, la última figura presente en los modelos de Netlogo es el observador. Éste no está representado en el mundo, pero puede interactuar con él (crea y destruye agentes, asigna propiedades a los agentes, etc).


Vistas en Netlogo (1)

Cuando arranquemos Netlogo, la pantalla de nuestro ordenador presentará el siguiente aspecto:




En la parte superior observamos tres pestañas: interface (interfaz), information (información) y procedures (procedimientos).

Aunque lo veremos con mayor detenimiento próximamente, en la primera de las pestañas (interface) será donde se represente nuestro modelo.

En la segunda pestaña (information) podremos añadir información sobre nuestro modelo para informar a los usuarios:



y en la última pestaña (procedures) escribiremos los procedimientos que se encargarán de llevar a cabo la ejecución de nuestro modelo:




Para más detalles, puedes consultar: Vistas en Netlogo (2).

viernes, 2 de agosto de 2013

Simulando juegos, gana la conducta cooperativa

Be nice. Evolution will punish you if you’re not, says study
Selfish people have short-term advantage, but co-operation and communication win out in the long term
JAMES VINCENT

New research has challenged the notion that evolution favours self-interest above co-operation, suggesting instead that selfish individuals eventually ‘compete each other out of existence’.


The study, published in the journal Nature, used models of evolutionary game theory (EGT) to show how co-operative populations are more successful than selfish ones in the long run.

Researchers used computers to play through vast numbers of “games” simulating scenarios of co-operation and betrayal. By tweaking the strategies of the virtual players they were then able to compare which behaviours resulted in survival.

The study pitched players following so-called “zero determinant” strategies (those who acted selfishly) against others taking more benevolent approaches. While the selfish strategists enjoyed a brief advantage, opponents eventually came to recognise and overcome selfish individuals.

“Communication is critical for cooperation – we think communication is the reason co-operation occurs,” said Christoph Adami, a professor at Michigan State University and the lead author of the paper. “In an evolutionary setting, with populations of strategies, you need extra information to distinguish each other.

“We found evolution will punish you if you’re selfish and mean. For a short time and against a specific set of opponents, some selfish organisms may come out ahead. But selfishness isn’t evolutionarily sustainable.”

Much of what we understand about the working of selfish and selfless behaviour in society comes from game theory, a branch of mathematics concerned with decision making. It was developed throughout the middle of the 20th century but came to prominence first through the works of John Nash and then as a guiding political ideology during the cold war.

One of game theory’s most infamous studies is the “prisoner’s dilemma”, a hypothetical scenario where two prisoners are offered their freedom if they inform on the other. Under Nash’s explanation it seemed to show that individuals should pursue their own interests because they cannot predict how others will act.

The problem with such examples is that they are abstract and theoretical – they don’t take into account the many nuances of real-world scenarios where individuals have the opportunity to gauge how trustworthy others are, discuss their options, and also evaluate other people’s past behaviour.

Despite the apparent humane message of the findings of the new research, they do not contradict the concept of the “selfish gene” – the theory that living organisms exist only to propagate their genetic material.

Instead, the findings may complement it, as co-operative behaviour benefits whole species and thus the existence of a wider gene pool. Co-operation within a group does not preclude selfishness outside of it.

The Independent

martes, 23 de julio de 2013

La necesidad de una ciencia social computacional

Let’s Shake Up the Social Sciences



TWENTY-FIVE years ago, when I was a graduate student, there were departments of natural science that no longer exist today. Departments of anatomy, histology, biochemistry and physiology have disappeared, replaced by innovative departments of stem-cell biology, systems biology, neurobiology and molecular biophysics. Taking a page from Darwin, the natural sciences are evolving with the times. The perfection of cloning techniques gave rise to stem-cell biology; advances in computer science contributed to systems biology. Whole new fields of inquiry, as well as university departments and majors, owe their existence to fresh discoveries and novel tools.


In contrast, the social sciences have stagnated. They offer essentially the same set of academic departments and disciplines that they have for nearly 100 years: sociology, economics, anthropology, psychology and political science. This is not only boring but also counterproductive, constraining engagement with the scientific cutting edge and stifling the creation of new and useful knowledge. Such inertia reflects an unnecessary insecurity and conservatism, and helps explain why the social sciences don’t enjoy the same prestige as the natural sciences.
One reason citizens, politicians and university donors sometimes lack confidence in the social sciences is that social scientists too often miss the chance to declare victory and move on to new frontiers. Like natural scientists, they should be able to say, “We have figured this topic out to a reasonable degree of certainty, and we are now moving our attention to more exciting areas.” But they do not.
I’m not suggesting that social scientists stop teaching and investigating classic topics like monopoly power, racial profiling and health inequality. But everyone knows that monopoly power is bad for markets, that people are racially biased and that illness is unequally distributed by social class. There are diminishing returns from the continuing study of many such topics. And repeatedly observing these phenomena does not help us fix them.
So social scientists should devote a small palace guard to settled subjects and redeploy most of their forces to new fields like social neuroscience, behavioral economics, evolutionary psychology and social epigenetics, most of which, not coincidentally, lie at the intersection of the natural and social sciences. Behavioral economics, for example, has used psychology to radically reshape classical economics.
Such interdisciplinary efforts are also generating practical insights about fundamental problems like chronic illness, energy conservation, pandemic disease, intergenerational poverty and market panics. For example, a better understanding of the structure and function of human social networks is helping us understand which individuals within social systems have an outsize impact when it comes to the spread of germs or the spread of ideas. As a result, we now have at our disposal new ways to accelerate the adoption of desirable practices as diverse as vaccination in rural villages and seat-belt use among urban schoolchildren.
It is time to create new social science departments that reflect the breadth and complexity of the problems we face as well as the novelty of 21st-century science. These would include departments of biosocial science, network science, neuroeconomics, behavioral genetics and computational social science. Eventually, these departments would themselves be dismantled or transmuted as science continues to advance.
Some recent examples offer a glimpse of the potential. At Yale, the Jackson Institute for Global Affairs applies diverse social sciences to the study of international issues and offers a new major. At Harvard, the sub-discipline of physical anthropology, which increasingly relies on modern genetics, was hived off the anthropology department to make the department of human evolutionary biology. Still, such efforts are generally more like herds splitting up than like new species emerging. We have not yet changed the basic DNA of the social sciences. Failure to do so might even result in having the natural sciences co-opt topics rightly and beneficially in the purview of the social sciences.
New social science departments could also help to better train students by engaging in new types of pedagogy. For example, in the natural sciences, even college freshmen do laboratory experiments. Why is this rare in the social sciences? When students learn about social phenomena, why don’t they go to the lab to examine them — how markets reach equilibrium, how people cooperate, how social ties are formed? Newly invented tools make this feasible. It is now possible to use the Internet to enlist thousands of people to participate in randomized experiments. This seems radical only because our current social science departments weren’t organized to teach this way.
For the past century, people have looked to the physical and biological sciences to solve important problems. The social sciences offer equal promise for improving human welfare; our lives can be greatly improved through a deeper understanding of individual and collective behavior. But to realize this promise, the social sciences, like the natural sciences, need to match their institutional structures to today’s intellectual challenges.
Nicholas A. Christakis, a physician and sociologist at Yale University, is a co-director of the Yale Institute for Network Science.
NYT

lunes, 22 de julio de 2013

Dinámica evolutiva en Netlogo con el replicador

Evolutionary Dynamics

Replicator Dynamics are a math formula meant to simplify the dynamics of evolution. But, we can code, we don't have to simplify.

In this video I show how to simulate simple evolutionary dynamics with more detail than before. The program, it turns out, is simpler than before.

Multi-Agents Systems