Inline theme hints?

Has any thought been given to some sort of inline theme configuration, right inside of the .als file?

Here’s the sort of thing I have in mind. I’m modeling a simple (existing) inventory control system, which keeps track of line items. When visualizing a LineItem, I want the id and qty to be attributes and not show as nodes, so something like this:

sig Item {}

// Theme: seq/Int node visible=no

sig LineItemUUID {}          // Theme: node visible=no

sig LineItem {
  id: disj one LineItemUUID, // Theme: edge attribute=yes
  item: one Item,
  qty: Int                   // Theme: edge attribute=yes
} {
  // Facts
  qty >= 0
}

or maybe something that maps more directly to the .thm file, a special comment at the top:

/* THEME:
 * <node visible="no"> <type name="seq/Int"/> </node>
 * <node visible="no" shape="Inv Triangle" color="Blue">
 *    <type name="LineItemUUID"/>
 * </node>
 * <edge attribute="yes">
 *    <relation name="id"> <type name="LineItem"/> <type name="LineItemUUID"/> </relation>
 *    <relation name="qty"> <type name="LineItem"/> <type name="Int"/> </relation>
 * </edge>
 */

sig Item {}
...

though that one isn’t as human-friendly, it might be easier to implement/maintain.

Anyway – the general idea is that there are some of these structural hints for the visualization that feel like they could live alongside the actual structures. Thoughts?

This has already been discussed in a few occasions, yes. The biggest issue is that several themes may be useful depending on the property at stake. The Visualizer also has limitations for certain types of models (eg if you want objects to remain in the same position).

Regarding your examples, rather than ad hoc special comments or machine-oriented XML, I would suggest assessing a third possibility. Namely to explore the creation of an Alloy Viz model representing the range of theming option, and then a way to describe a theme for you Inventory model as a relation between both models. Then a special treatment of the Viz model in the Alloy Analyzer would produce the adequate visualization. I think something along these lines (using a so-called “a Visual Language Model”, perhaps more sophisticated than the Viz model) had been explored by L. Gammaïtoni a decade ago. Might be interesting to revive this approach.

Ah, interesting idea! OK, thank you. I haven’t done a ton with themes already, especially around usefully having multiple themes for visualizing the same model. So I should probably spend more time there as well.

One of my intentions with the json files is to make it useful for the browser. d3 is a wet dream come true for animated visualizations.