Skip to content

A Traditional Britmas

This post has 807 words. Reading it will take approximately 4 minutes.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)

In the days December 21st to 27th I went to Denmark for the annual “let’s get drunk because some fictional person got his birthday retconned to this time”-celebrations.

I landed in Billund in the evening and after what seemed to be remarkably few problems got on a bus to Århus. There, I did the only sensible thing and went with Ute to Die Kleine Bierstube:

As the evening progressed, we got creative and built what may be the most important piece of art on this side of the Apocalypse1): Julesaddam (Britmas Saddam or Saddam Claus), a wonderful merger of Santa Claus and Saddam Hussein.  There was much rejoicement:

No, the picture is not blurry, that is also how I remember the evening.

On the 22nd, the traditional HEST christmas lunch takes place.  I only snapped one picture because…  Of the reason.

The image has been censored to protect the identities of the guilty.  Not 100% sure what they’re guilty of, but I know them, and they’re probably guilty of something.  In case you were wondering about the reason above, here it is:

On the 23rd we went to Cockney Pub to get drunk with Mr. Mike.  You can see him talking to us here:

For some inexplicable reason, there was music that night at the pub (it’s a Britmas miracle!), so Mike and Celia deemed it necessary to dance.  So it was:

On the 24th it was time for the obligatory case of LFP and an Ardbeg.  Also green risalamande (a Danish misspelling of the French riz à l’amande or rice with almond).  As a new fun thing, we also painted the duck green:

That way, you know it is biological.  Or poisonous.  I forgot what green means in the game of life.

After eating half of our food, we wanted to go pubbing  ((Is that a word?  It’s like clubbing except more about going to pubs.  Now it’s a word – the English language is my bitch!)), and left for Agners.

On the way, we made a short-cut thru the Physics department, and saw that somebody has distributed TÅGEKAMMERET flyers.  That is small almost useless pieces of paper with retarded musings on the back side.  We found that weird as TK was supposed to be closed for Britmas…

Unfortunately, Agners was closed despite rumors to the contrary.  Instead we went to Værtshuset, where we got a finite and large but not large enough number of Ceres Top.  After that Super Mario World.

On the 25th we tried to get rid of the remaining LFP2).  For some reason this resulted in me getting red nail polish on one foot and one hand.

So, that has been fun to explain ever since – especially on the 26th.  Speaking (not really) of the 26th, that day I went to see my family.  No pictures from that.  On the 27th I flew home, helped by a KLM plane.  While I may seem like Superman to you, I cannot in fact fly by my own means.  Yet.

On the 28th I went to a quiz at Dommel 18 (and late in the evening, Edwin shot this video of me being all Britmassy) and on the 29th to another quiz at Carrousel.  Don’t have any pictures of that, but here’s one I stole from Facebook from another evening:

On the 30th Spiegelbeeld had last opening day of the year, and hence celebrated by a beer festival.  There are many reasons to like Spiegelbeeld (nice affordable food and great beers), but one especially is near and dear to me.  If you look at their logo:

and imagine it being drawn on the windows (which it is).  Now imagine the logo from the other side.  I’ll put my CSI-like computer skills to use to display what that may look like:

Now, imagine, for a second if you please, that you happen to be a huge Britney Spears fan…

No, silly3)!

Anyway, beer festival with heaps of nice beer, beer tasting (I got the one I tasted in one guess, so that’s nice), and a raffle.  Also, sausage and cheese:

I also recall there was beer…  That is all a bit hazy…

Finally, on the 31st, oud-en-nieuw at Dommel 18.  Super party.  I got this spiffy arm band:

Included in the €45 open bar, I also got a lot of these:

I got so many I at some point thought it would be a good idea to drink vodka shots plus Jack and Ginger.  It was not.

Now, 2012…  Let’s see if those Mayans are right


  1. See how I’m trowing Jesus references around like were they kids. []
  2. The Ardbeg somehow disappeared in a SMW-related accident.  It was no accident – we drank it. []
  3. I’d like to dedicate another high-quality Photoshop to Julinka. []

Britmassy

This post has 28 words. Reading it will take less than one minute.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)

There! I’ve put up the Britmas decorations.  Super-late or Super-early?  I be the judge, because you sure as Aguilera aren’t qualified.

Simulated Naughtiness in CPN Tools

This post has 1352 words. Reading it will take approximately 7 minutes.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)

Today I got a question about simulating a sequence of named transitions in CPN Tools.  While this is not immediately possible, it can be done using Access/CPN, which has a Java component (featured here ) and a SML component, which is leading a much more secret life as the underpinning of ASAP.

Access/CPN is described in the papers

  • [PDF] M. Westergaard and L. M. Kristensen, “Two Interfaces to the CPN Tools Simulator,” in Proc. of 9th CPN Workshop, 2008, pp. 83-102.
    [Bibtex]
    @InProceedings{siminterface,
    Author         = {Westergaard, Michael and Kristensen, Lars Michael},
    Title          = {{Two Interfaces to the CPN Tools Simulator}},
    BookTitle      = {{Proc. of 9th CPN Workshop}},
    Volume         = {588},
    Series         = {DAIMI-PB},
    Pages          = {83-102},
    year           = 2008,
    }
  • [PDF] [DOI] M. Westergaard and L. M. Kristensen, “The Access/CPN Framework: A Tool for Interacting with the CPN Tools Simulator,” , G. Franceschinis and K. Wolf, Ed., Springer Berlin / Heidelberg, 2009, vol. 5606, pp. 313-322.
    [Bibtex]
    @incollection{accesscpn,
    author = {Westergaard, Michael and Kristensen, Lars Michael},
    affiliation = {Aarhus University Department of Computer Science Denmark},
    title = {The Access/CPN Framework: A Tool for Interacting with the CPN Tools Simulator},
    booktitle = {Applications and Theory of Petri Nets},
    series = {Lecture Notes in Computer Science},
    editor = {Franceschinis, Giuliana and Wolf, Karsten},
    publisher = {Springer Berlin / Heidelberg},
    isbn = {},
    pages = {313-322},
    volume = {5606},
    doi = {10.1007/978-3-642-02424-5_19},
    note = {10.1007/978-3-642-02424-5_19},
    abstract = {Coloured Petri nets (CP-nets or CPNs) is a widely used formalism for describing concurrent systems. CPN Tools provides a mature environment for constructing, simulating, and performing analysis of CPN models. CPN Tools also has limitations if, for example, one wishes to extend the analysis capabilities or to integrate CPN models into external applications. In this paper we present Access/CPN, a framework that facilitates such extensions. Access/CPN consists of two interfaces: one written in Standard ML, which is very close to the simulator component of CPN Tools, and one written in Java, providing an object-oriented representation of CPN models, a means to load models created using CPN Tools, and an interface to the simulator. We illustrate Access/CPN by providing the complete implementation of a simple command-line state space exploration tool.},
    year = {2009}
    }

The idea is to use Access/CPN to execute the transitions and then force the GUI to update itself after the fact.  The SML component of Access/CPN is instantiated using the Enter State-space tool of CPN Tools.  Starting with version 3.2, CPN Tools has an extra option which loads the ASAP tool instead of the old one in CPN Tools.  See more about ASAP in CPN Tools here.

Now, we have access to the structures Bind and ASAP.CPNToolsModel (and a couple others as well, but let’s not worry about those here).

Let us consider the model below:

Let’s assume that we want to perform some setup, so we need to execute first a with n = 1 and then b (also with n = 1).  To do that, we can use the executeSequernce function of ASAP.CPNToolsModel.  The function has interface:

executeSequence: state * event list -> (state * event list) list

Thus, we need to give a source state and a list of events to execute.  The result is a set (list) of states and enabled events, namely the result of executing the event sequence (which we ignore).  We can use the function

getInitialStates: unit -> (state * event list) list

to get the initial state (the interface allows multiple initial states to handle non-deterministic models, but the function always returns exactly one for CPN models).

The Bind structure contains a type event which is a union of a value for all transitions in the model.  Transitions are described using two values, an integer indicating the instance number (the number shown next to the page name or 1 if none is shown) and the binding of all variables.

We thus devise the code:

let
open Bind ASAP.CPNToolsModel
val [(s, _)] = getInitialStates()
val r = executeSequence (s, [Top'a (1, { n = 1 }), Top'b (1, { n = 1 })])
in
CPN'Sim.reset_scheduler()
end

We first open the structures we need (l. 2) and obtain the initial state using pattern matching to only get the actual state descriptor (l. 3). We then execute the desired sequence of events. Here, we execute transition a on instance 1 of the page Top in the binding n = 1, then the transition b on the same page in the same binding. In line 6 we reset the scheduler. We need to do this as we are executing transitions without using the scheduler. Read more about the scheduler in a separate post.

Now we are nearly done: CPN Tools has actually executed the events, but the GUI does not reflect this. To reset the GUI, we need to fast forward (at least) one step.  This may execute any transition, however, so we use a trick to ensure that a particular transition without importance is executed.  The construction is shown below:

The idea is that the low-priority transition will never be executed until no other transitions are enabled and the high-prioritry transition will be executed before all others.  The trick is that using Access/CPN to execute transitions allows us to execute the low-priority transition even though it is not enabled (it is only pre-enabled).  See more about priorities in

  • [PDF] M. Westergaard and Verbeek, “Efficient Implementation of Prioritized Transitions for High-level Petri Nets,” in Petri Nets and Software Engineering. International Workshop PNSE’11, 2011, pp. 27-41.
    [Bibtex]
    @InProceedings{priority,
    author =   {Westergaard, Michael and Verbeek, H. M. W.},
    title =   {Efficient Implementation of Prioritized Transitions for High-level {Petri} Nets},
    pages =   {27-41},
    booktitle =   {{Petri} Nets and Software Engineering. International Workshop PNSE'11},
    editor =   {Duvigneau, Michael and Moldt, Daniel and Hiraishi, Kunihiko},
    month =    jun,
    year =    2011,
    volume =    723,
    series =    {CEUR Workshop Proceedings},
    ISSN =    {1613-0074},
    publisher =    {CEUR-WS.org},
    url =    {http://CEUR-WS.org/Vol-723},
    urn =    {urn:nbn:de:0074-723-C}
    abstract =    {Transition priorities can be a useful mechanism when
    modeling using Petri nets.  For example, high-priority
    transitions can be used to model exception handling and
    low-priority transitions can be used to model background
    tasks that should only be executed when no other
    transition is enabled.  Transition priorities can be
    simulated in Petri nets using, e.\,g., inhibitor arcs,
    but such constructs tend to unnecessarily clutter models,
    making it useful to support priorities directly.
    
    Computing the enabling of transitions in high-level Petri
    nets is an expensive operation and should be avoided.  As
    transition priorities introduce a nonlocal enabling
    condition, at first sight this forces us to compute
    enabling for all transitions in a highest-priority-first
    order, but it is possible to do better.  Here we describe
    our implementation of transition priorities in CPN Tools
    3.0, where we minimize the number of enabling
    computations.  We describe algorithms for executing
    transitions at random, useful for automatic simulation
    without user interactions, and for maintaining a set of
    known enabled transitions, useful for interactive
    user-guided simulation.  Experiments show that using our
    algorithms we can execute $4-7$ million transitions a
    minute for real-life models and more than $20$ million
    transitions a minute for other models, a significant
    improvement over the $1-5$ million transitions a minute
    possible for simpler algorithms.}
    }

Combining it all yields this model:

You can also get the model as a model for CPN Tools here.  Note that we have added the low-priority transition at the end of the list of transitions to execute.  The model is used by loading it in CPN Tools.  Then the ASAP option is switched on for the Enter State Space tool and the tool is used on the model.  Entering the ASAP tool instead of the old one normally used in CPN Tools is significantly faster.  Now, the auxiliary text is executed using Evaluate ML.  Finally, we Fast Forward, making sure to set the number of steps to skip ahead to 1 beforehand if it isn’t already set to that.  The model is now in a state, where A contains 1`2 and C contains 1`1 and the other places are empty.

The constructions used are completely generic, which is why they may seem a bit complicated.  The priority construction does not introduce new behavior (as long as we ensure that the priorities are indeed lower than/higher than all other used priorities).  Dead-locks are preserved and (I’m fairly certain but haven’t bothered to prove) so are LTL properties.

Productivity Boost

This post has 35 words. Reading it will take less than one minute.

VN:F [1.9.13_1145]
Rating: 5.0/5 (1 vote cast)

Just used Air Display to set up a 3rd monitor at the office.  This allows me to work while I watch the Femme Fatale tour, thereby vastly improving productivity ;-)

Exploiting the Innards of ProM and Breaking Data-Hiding for Fun and Profit

This post has 1301 words. Reading it will take approximately 7 minutes.

VN:F [1.9.13_1145]
Rating: 0.0/5 (0 votes cast)

So, I’ve spent the afternoon writing horrible code.  Horrible, horrible code.

See, I have this plug-in, which executes other plug-ins.  For some time, I’ve wanted to mark those as favorite in ProM.  This means that the object shows up with a pretty yellow star and, more importantly, shows up in the Favorites.  As the Favorites tab is the default and ProM normally puts everything here itself, most users never switch to the All tab and cannot find the object created by my plug-in.  Thus, instead of this:

we would like this:

Now, ProM is designed to run in multiple modes.  The standard one that most people see is the graphical UITopia mode.  Here we have a graphical context where all of the above makes sense.  ProM also has a command line mode and a distributed mode, where we do not have the graphical context available and cannot do this.

Normally, when you register an object, you do something like this:

public static <T> void publish(final PluginContext context, final String name, final T object,	final Class<? super T> clazz, final boolean favorite) {
	final ProvidedObjectID id = context.getProvidedObjectManager().createProvidedObject(name, object, clazz, context);

We get the ProvidedObjectManager and registers our object with the correct name and type (the type is important, as ProM only shows exact objects it knows, not any sub-types). Unfortunately, this produces the situation above: object is without a star and hidden behind the All tab along with all kinds of scary and internal objects. Nobody wants that.

Now, we do a type check on the context to check if it is a UIPluginContext, i.e., it is running in graphical mode. If it is, we have some more, very internal, methods available. We can get access to the GlobalContext, which provides access to all the innards of ProM. As such:

if (context instanceof UIPluginContext) {
	final GlobalContext gcontext = ( (UIPluginContext) context).getGlobalContext();

Now, a GlobalContext in itself is a bit boring, but if the GlobalContext is a UIContext (which it is in the graphical case), we have found the proverbial pot of Britney CDs at the end of the rainbow. The thing is that the UIContext has access to a Resource Manager, which is used for handling resources. The resource manager can be used to register a new resource, which in turn can be marked as a favorite. Lets hijack that son of Aguilera:

if (gcontext instanceof UIContext) {
	final UIContext uicontext = (UIContext) gcontext;
	final ResourceType resType = uicontext.getResourceManager().getResourceTypeFor(clazz);
	if (resType != null) {
		final List<Collection<ProMPOResource>> lst = Collections.emptyList();
		ProMPOResource res = new ProMPOResource(uicontext, null, resType, id, lst);
		res = uicontext.getResourceManager().addResource(id, res);
		res.setFavorite(favorite);

We have now set our resource as favorite and it shows up appropriately in the Favorites tab.

But we are not completely done yet… We would also like to show the resource if possible. This is quite easy: the UIContext has a View Manager, which we can use to get all possible views for a type of resource instantiate one, and register it. We add this:

if (favorite) {
	final List<ViewType> viewTypes = uicontext.getViewManager().getViewTypes(res);
	if (viewTypes.size() > 0) {
		final ViewType viewType = viewTypes.get(0);
		final View view = viewType.createView(res);
		uicontext.getViewManager().addView(view);

We simply, if the object is marked as favorite, get all views of the appropriate type, and, if there are any, pick the first and create a view from it. Finally we add it to the view manager. Simple.

Again, we could call it a day at the office and head for the pub. We are not going to do that, because it wold be much more elegant to have the view also shown to the user; currently it is simply available and can be shown manually. Now, this is really dependent on the internals of the GUI, so it is a bit more difficult…

It turns out, however, that ProM has a UITopia Controller, which has access to the main view. Using this, we can switch to the views view1) and select the newly created one as the one shown as such:

final UITopiaController controller = ...;
controller.getMainView().showViewsView();
controller.getMainView().getViewsView().showFullScreen(view);

Now, of course, the problem is, how do we get a hold of the controller? Well, the UIContext has it. Looking in the UIContext class, we see:

public class UIContext extends AbstractGlobalContext implements FrameworkHub<ProMAction, ProMTask, ProMResource<?>, ProMPOResource> {
	...
	private UITopiaController controller;

We just use the accessor method on UIContext and Bob’s your uncle… Problem number next: The controller is not accessible. Nor is it (to the best of my knowledge) accessible from anywhere I have access to…

This, of course is fixable. Using reflection, we have access to private fields, so we “just” write some wonderful code like this:

final Field controllerField = uicontext.getClass().getDeclaredField("controller");
controllerField.setAccessible(true);
final UITopiaController controller = (UITopiaController) controllerField.get(uicontext);

Yes, the solution is to find David Parnas, hit him with something heavy, tear out his heart, and then completely shit all over data encapsulation. We “simply” get the field descriptor for the controller, modify the access rights, and get the value. Simple.

Tying all of this together in a single piece of code yields the below method. It is ugly as an Aguilera song, but works. It even gracefully degrades2), i.e., if we are running on the command line, the object is just registered, and if we cannot access the private field, we just ignore it and neglect to raise the view to the front. In addition to the code explained above, we also actually provide a value for the action in line 37 (the second parameter) which we obtain from the context using the same strategy used to get the controller.

	/**
	 * Will publish object as a provided object with the class specified by
	 * clazz. If the context is a UIPluginContext and favorite is true, it will
	 * be marked as a favorite object as well. Finally, if it is marked as
	 * favorite, it will also be show and ProM will switch to the Views tab.
	 * Encapsulation is for scared little boys/girls who still believe in the
	 * invisible pink unicorn (IPU).
	 *
	 * @param <T>
	 * @param context
	 * @param name
	 * @param object
	 * @param clazz
	 * @param favorite
	 */
	public static <T> void publish(final PluginContext context, final String name, final T object,
			final Class<? super T> clazz, final boolean favorite) {
		final ProvidedObjectID id = context.getProvidedObjectManager().createProvidedObject(name, object, clazz,
				context);
		// Do not look at the rest of this method.  Boudewijn was busy and I just decided to do what is necessary.
		// It works.  It probably breaks if somebody changes anything.  Here or elsewhere.
		if (context instanceof UIPluginContext) {
			final GlobalContext gcontext = ((UIPluginContext) context).getGlobalContext();
			if (gcontext instanceof UIContext) {
				final UIContext uicontext = (UIContext) gcontext;
				final ResourceType resType = uicontext.getResourceManager().getResourceTypeFor(clazz);
				if (resType != null) {
					ProMTask task = null;
					try {
						final Field taskField = context.getClass().getDeclaredField("task");
						taskField.setAccessible(true);
						task = (ProMTask) taskField.get(context);
					} catch (final Exception _) {
						// Guess it wasn't meant to be, then...
					}
					final List<Collection<ProMPOResource>> lst = Collections.emptyList();
					ProMPOResource res = new ProMPOResource(uicontext, task == null?null:task.getAction(), resType, id, lst);
					res = uicontext.getResourceManager().addResource(id, res);
					res.setFavorite(favorite);
					if (favorite) {
						final List<ViewType> viewTypes = uicontext.getViewManager().getViewTypes(res);
						if (viewTypes.size() > 0) {
							final ViewType viewType = viewTypes.get(0);
							final View view = viewType.createView(res);
							uicontext.getViewManager().addView(view);
							try {
								final Field controllerField = uicontext.getClass().getDeclaredField("controller");
								controllerField.setAccessible(true);
								final UITopiaController controller = (UITopiaController) controllerField.get(uicontext);
								controller.getMainView().showViewsView();
								controller.getMainView().getViewsView().showFullScreen(view);
							} catch (final Exception _) {
								// Not a huge surprise, really...
							}
						}
					}
				}
			}
		}
	}

  1. Wonderful name… []
  2. Much unlike Aguilera who has hit rock bottom but still ungracefully degrades herself by singing her own songs instead of Britney’s. []