How to turn an AnyLogic population into a DAG

Want to know how to turn an AnyLogic population into a Directed Acyclic Graph? This is even better than a new pair of heels!

A zillion thank yous to the JGraphT project founders and maintainers and also to Peter Giles at U Washington for contributing the dynamic DAG implementation. WOWZA this rocks!

So... I have a population of Agents in Anylogic. I would like to arrange them in a random Directed Acyclic Graph.

Here is what I did.

1. In Main, under the advanced tab, import:

import org.jgrapht.demo.*;  
import org.jgrapht.*;import org.jgrapht.graph.*;
import org.jgrapht.experimental.*;
import org.jgrapht.experimental.dag.DirectedAcyclicGraph.CycleFoundException;
import org.jgrapht.experimental.dag.DirectedAcyclicGraph.*;import org.jgrapht.experimental.dag.*;

2. Download jGraphT and add the Jar to the Anylogic Dependencies. You can do this by clicking on your project name and there is a Dependencies tab. http://www.jgrapht.org/

3. Set the Replication of your agent population to be myAgent.size() where myAgent is the variable name you gave to the population.

4. Create a loop from 0 to whatever number of agents you want, and for each iteration go like

MyAgent newLO = add_myAgent("parameter1", "parameter2");
directedAcyclicGraph.addVertex(newLO);

... where MyAgent is whatever kind of Java class that your population is. And directedAcyclicGraph is a variable in your Main of type

 DirectedAcyclicGraph< MyAgent, DefaultEdge >
which you just imported from the JGraphT library. You can set the Initial Value to be

new DirectedAcyclicGraph< LearningObjectAgent, DefaultEdge >(DefaultEdge.class);


The method add_myAgent is automaticaly created for you by AnyLogic and you can find it in Main. Whatever the arguments are to the constructor are whatever the Parameters are that you put into that agent type.

5. So if you want to add some random edges to the DAG just pick any member of the MyAgent population, pick a random neighbour and badda bing badda boom

MyAgent randomNeighbour= myAgent.random();
try {
	directedAcyclicGraph.addEdge(myAgent,randomNeighbour);  //myAgent and randomNeighbour are both of type MyAgent
	myAgent.connectTo(randomNeighbour);  //i just did this so it could print a pretty graph.
       //unfortunately, I have only drawn regular lines between nodes, so there is no way to tell the edge direction from the visualization... u have to rely on the edge-printout which uses an ordered pair like (sourcenode, destinationnode)
} catch (IllegalArgumentException dcfe) {
        //oops, this means that connecting to this particular random neighbour would have created a cycle
	myAgent.disconnectFrom(randomNeighbour);
}
 

shaZAHM!

Posted by Frozone Permalink on February 04, 2012 04:58 PM | Comments (0)
categorized under Tool Configuration




Texting

For the second time in my life today, I sent a text message. Wooo! The first one was to my brother, the second one was to a friend.

The text message to my brother worked great, although it took me a reaaaaalllyyy looooonggg time to type it in. Do people actually do this regularly? There is no way I'm going to incorporate texting into my day to day life because I would get interrupted 4 or 5 times before I even finish typing, it, and then I will forget what I wanted to say!!

But I'm glad I gave it a try. On my second text message, it said "Error! Not sent, saved in Outbox. Please try again later." Then I went into details and it said "Cause code: 96". Obviously, I called the tech support. I didn't know why texting worked with my brother and not with my friend. It also fails for texts I send to my husband. The helper said that I should check to make sure I put in the area code, even for a local call. He was right! Since my brother lives in another province, I had the area code in by default, but since my friend and husband live in the same province I hadn't bothered to put in the area code.

COOL! So I can do texting now.

Posted by Frozone Permalink on February 02, 2012 12:08 PM | Comments (0)
categorized under fun, art, music, people, misc




MySQL import

Another one of those things I've done a dozen times but can't remember the details...

cd /usr/local/mysql/bin   (unneccessary but including this so i can remember where the heck it is installed lol)
mysql -u username -p dbname < dbname.sql

Booya

Posted by Frozone Permalink on January 18, 2012 01:27 PM | Comments (0)
categorized under Tool Configuration




The Creation Story, with Geometry and Spirituality

Yesterday, I took vacation from work so I could do some schoolwork. Around lunchtime, I decided to take a break. I had a gift card in the bookstore from my Auntie H. which was probably over a year old. It's been a long time since I've allowed myself to go shopping. Anyway, I picked up a book called "How the World is Made: The Story of Creation According to Sacred Geometry" by John Mitchell with Allan Brown.

Regarding this particular blog entry, I worry a little about being hastily judged for being interested in this New Age pseudo-science Hocus Pocus, but I am really attracted to this stuff. I love it. And I KNOW it's not real science unless you can measure it. I can still be interested in it and read about it, right? The same goes for reading from teachers like Penczak, whom I've alluded to before.

Anyway, I was just charmed by this creation story. I was also attracted to the term "Creation Story" because I am an employee at the University of Saskatchewan, which is actively trying to heal relationships and ties to the aboriginal peoples of this land, where "it" as the U of S contains both the "white man settlers" perspective and the indigenous people perspective, because "we" are all the U of S. But unfortunately the "white man setters" perspective is still dominant and damaging, but is slowly healing, hopefully. Through my privilege as a U of S employee, I have been given opportunities to listen to teachers like Dr. Maria Campbell and Dr. Winona Wheeler. Largely because of my afternoon with these teachers, I was already on track to look for different ways of understanding.

It's too bad that I felt I had to justify before continuing, but, there we have it. On with my point.

Thanking these "teachers", Mitchell, Brown, Penczak, Campbell and Wheeler, I want to share my interpretation of this creation story. Some of the original ideas from these independent teachers have been combined together and reinterpreted by myself below. Wouldn't this be a fun story to tell in a first year computer science or math class?

P.S. Thanks to Zwibbler.com for this awesome tool!


Creation Story

Once upon a time, the Creator decided to make the universe and began by drawing a circle to make the boundary of what the universe is. This act also created the first sacred ratio, 1 to pi, or, the ratio between the diameter (=1) and the circumference (=pi).






Then, the Creator made 2 axes.

Why 2 axes? Because this is the minimum number to create the next sacred ratio, between the "hypotenuse" and the length of a side of a square. The first axis is just a line drawn through the circle. You can think of this as the hypotenuse of a triangle-to-be, or, also the diagonal of a square-to-be. Pick the one that resonates best with you.



This is also when energy of the universe is divided into the four main elements of earth, air, fire and water, represented by the square. (Note: Everyone knows that there are not literally 4 elements but rather the periodic table with 118 elements. I believe it was Penczak who suggested that you think of the terms Earth, Air, Fire and Water to be more like analogies to the "feeling" of that type of energy, i.e. earth = heavy, steady, home; air = intellectual, lightweight; water = emotional; fire=initiation, spark, starting up).

Third, another circle is drawn around this square. Now that there are two circles, inner and outer, this is when "spectrums" were born, like scales with extreme values and values in between: Up/down, Light/Dark, Hot/Cold, Open/Closed, Male/Female, 0/1, etc..

Next, you take our "triangle" from earlier and shrink it so it fits inside the smaller circle. Duplicate it and rotate to make 2 equilateral triangles. The third sacred ratio is between the short and long diagonals of the rhombus. The short line = 1 (i.e. the length of one of the six lines to make the star) and the long line = root 3 (i.e. the distance between two opposite points).

The story keeps going, But that's as far as my brain can handle right now. I feel super pleased because now I have an emotional attachment to these ratios, which I never had before. It can make building up from these for understanding future mathematical concepts easier and more fun.

Posted by Frozone Permalink on January 14, 2012 06:36 PM | Comments (0)
categorized under Being at Home




Lingo: "Student" or "Learner"?

When I first started work in this field, I called the users of the educational systems I was working on "Students".

But then as I continued work I realized that educational systems are for EVERYONE, and not only for people formally registered with some sort of educational institution. Think: adult learners, corporate classroom, hobbyists, etc.. All of these people could be users of an educational software system, but, the word "student" may not be appropriate.

Now it is a couple of years later and I'm definitely in the habit of saying "learners" all the time without thinking about it. But now that I'm firmly into grad school and have had to do a lot of denser writing about my work, I see that as I have to explain "learning objects" and "learners" a lot, it's hard on they eyes and hard on the mind to try and keep these two separate when you are reading quickly because they both have the same sequence of letters "learn-" inside of them. Nobody has ever pointed this out to me, but it's something that's been bothering me lately as I've been re-reading my own work.

It's also surprisingly hard on me when I try to give a talk. Talk about tongue twisters!

So, as of today I am switching back to using "student". I shall declare to the world that even though I say "student" I mean anyone who wants to do any form of learning.

Skidoosh! (I just thought I would conclude my blog entry with a random reference to Kung Fu Panda. Awesome movie.)

Posted by Frozone Permalink on January 14, 2012 11:52 AM | Comments (0)
categorized under Student Modelling




MySQL crazy symbol problems

Thanks to Chris P. for letting me know how to fix crazy symbol problems in MySQL by changing the character set to be utf8. The default is like latin sweedish or something.
(Reference:
http://kb.siteground.com/article/How_can_I_change_my_MySQL_database_collation.html)

Here's the actual SQL to do it (because frequently I don't have phpmyadmin installed):

ALTER DATABASE 'databasename' DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Posted by Frozone Permalink on January 11, 2012 02:57 PM | Comments (0)
categorized under Tool Configuration




How many objects in a Learning Object repository?

This is one of the most relevant / applicable papers I have read in a long time: Learnometrics: metrics for learning objects Author: Xavier Ochoa, LAK '11 Proceedings of the 1st International Conference on Learning Analytics and Knowledge

It addresses questions like:

What is the typical size of a repository?
What percentage of learning objects is reused?
Is there a relation between the popularity of an object and its reuse?

This is AWESOME stuff. I remember setting up a simulation model in the past thinking, "What should I set 'n' for the learning object population?" and "Should I just make the LOs used randomly? Should a certain percentage of them have higher likelihood of being visited?" This LAK2011 paper gives some real data that a simulation model could be calibrated against.

Posted by Frozone Permalink on January 11, 2012 06:46 AM | Comments (0)
categorized under Semantic Web




True story: Lost mouse

This is a true story. It happened to me, today.

It's Monday morning, and I decide to get my desk back in order now that the holidays are officially over. I faintly recall packing my wireless mouse away at the end of December, deciding to use my trackpad on the laptop while my office is in sleep mode for a couple weeks.

Anyway, this morning I can't find the mouse anywhere. I check the communal equipment drawers with extra USB cables, other mice, etc. but I can't find mine. I check my own filing cabinet, certain it's there, but it's not. I check my bookshelf. I check every zipper and pocket in the satchel I carry between home and work every day. I rummage all around my desk, looking under papers and books. I check my filing cabinet again, because I know that's exactly where I would put it if I were packing it away. I check my bookshelf again. I consider asking my colleagues whether they've seen it, but I don't. I post a silly message on my status update saying how embarrassing this is that I actually lost my computer mouse. I mean, who loses their computer mouse? Apparently, me.

The story gets better.

After I glumly accept that maybe I can survive without my mouse after all and use my trackpad, and I really can't afford to waste any more time on this, I glimpse to the left of my laptop. There's my mouse. Right there. My desk is quite clean and clear and there are no papers within reach to even obscure the view. The mouse is right exactly next to my laptop, on the left. Normally, I keep my mouse on the right side of my laptop. Oh. My. Gosh. Seriously?

So, there we have it. If you ever feel like you have done something silly, I invite you to come and read this blog entry. Perhaps it will make you feel better.

Love, Frozone

Posted by Frozone Permalink on January 09, 2012 10:48 PM | Comments (0)
categorized under Random stories




Funnies with Timestamps

This is my second funny experience with a simulation environment. (Here's the first one, previous entry called Simulation funnies).

I am working with the Ecological Approach, which means that each time a Learner uses a Learning Object, a "stamp" of the current Learner Model is saved on the Learning Object.

In my simulation model, I have Learners randomly visiting learning objects and leaving stamps as they go.

At one point, I have to query to do a search for a particular Learner Model Stamp. For a primary key, I had (LearnerID, LearningObjectID, timestamp). Because a student would never visit the same learning object two times in the exact same millisecond. Right? Wrong. My hotshot computer is so fast and I have a small enough number of learners and learning objects that I did actually have duplicates, so, my "primary key" was not unique after all.

That's the funny part. hahaha, get it?

Anyway, to fix it, I decided just to insert a deliberate pause after each visit to guarantee the unique timestamp. This will slow down my simulation, obviously, but this is OK because I was already getting WAY more interaction than necessary for my model.

Posted by Frozone Permalink on January 07, 2012 03:09 PM | Comments (0)
categorized under Methodology




AnyLogic and Databases

Weird....

in AnyLogic, you can include Startup Code, and AnyLogic will execute it as it boots up your simulation model. So, I have a function called startUp() which calls all of the other functions in the correct order that I want. Two of these functions include MySQL database calls.

This has happened to me a couple of times so I thought I'd write it down. I noticed that for whatever bizarre reason, the functions inside startUp() that did database work were basically being ignored. Naturally this messed up a lot of my other stuff. I didn't notice this was happening, because it was working perfectly, until I started "clean up" and was deleting buttons from my interface and just adding the functions into my startUp() because I knew I wanted the stuff to run as part of my default model setup.

Since code works perfectly if I execute those functions with a button press instead of including them in my startUp(), my solution is to take the code back out of startUp(), create special buttons just for those, and press them every single time I boot up my model.

Annoying and weird, but at least it works.

By the way, if you don't know what AnyLogic is and are interested, I highly recommend Dr. N. Osgood's online resources which include some information about using AnyLogic with databases. (Material for Agent-Based Modeling Bootcamp for Health Researchers 2011Click the first link that reads, "lecture slides"). I learned about AnyLogic myself from taking his class, Computer Science 858 at the University of Saskatchewan, during the Winter (January) Term in 2011.

Posted by Frozone Permalink on January 07, 2012 02:14 PM | Comments (0)
categorized under Tool Configuration