Practical exercises in Empirical Modelling

A guided walk is a useful way to get some familiarity with a locality, but nothing beats making your own path for really helping you to explore and appreciate your surrounding. This task comprises three practical exercises in using Web EDEN. These will illustrate the way in which the underlying Eden notation, into which Scout and Eddi are both translated, can blend different modes of observation and representation. The Eden notation is the principal notation in the Web Eden environment. In practical terms, using the Eden notation means entering definitions into the Input Window with the tab on the bottom left of the input window showing "eden". If required, you can always switch the input to accepting Eden by inputting a "%eden".

Exercise 1: Adapt the Sudoku grid to make a simple form of electronic blackboard on which to demonstrate primary school arithmetic.

To start Exercise 1, click the top button from the button menu. The (blank) Sudoku grid will be replaced by a group of seven cells selected from the top left 3 by 3 region of the grid. These are the cells B1, C1, B2, C2, A3, B3 and C3. You have to introduce suitable definitions in the Eden notation, so that if you enter 2 digit numbers into the pairs of cells (B1, C1) and (B2, C2) then the triple of cells (A3, B3, C3) expresses the result of adding them together. For instance, if you were to type 3 and 4 into the cells B1 and C1, and type 7 and 7 into the cells B2 and C2, then A3, B3 and C3 would all display the digit 1. (This aspect of the exercise is of special interest to cricketers.)

Helpful pointers

Useful things for you to know can be found in the first section of Workshop 2A. For instance, the string that determines the content of the cell B2 is called b2, and its value is defined to be the value of the string representation of the digit that is recorded in Eden as b_2. You will only need to devise definitions for a_3, b_3, c_3 etc - if you need to introduce new observables, you can use names such as num1, num2, ... etc. For instance, the definition:

%eden

num1 is b_2 + c_3;

will make num1 the sum of the digits in the cells B2 and C3.

A note on definition and assignment

To define a to be the sum of b and c in Eden you introduce the definition:

a is b+c;

Note that a definition differs from an assignment which would be denoted by:

a = b+c;

This sets the current value of a to the sum of the current values of b and c, but the value of a will not change if those of b and c subsequently change. ( Note that, just to confuse you, the "=" in Scout which featured in Workshop 2A designates definition rather than assignment.)

Arithmetic in Eden

The standard arithmetic operations: subtraction (-), multiplication (*) and division (/) are available should you need them. Division returns an integer result ("the number of times you can subtract n from m before the remainder is smaller than n"), so that (m/n)*n is not necessarily equal to m. The remainder on dividing m by n is denoted by m. If you are unfamiliar with any of these operations, it is a good idea to devise a small set of definitions with which you can experiment. By way of further illustration:

%eden

num1 is (b_2 + 2*c_2)

b_3 is num1 + 1;

will define the value of num1 as the remainder you get when you add the digit in cell B2 to twice the digit in cell C2 and divide by 7. It will then display the digit num1+1 in the cell B3.

The classical computer programming problem

This is a good point at which to introduce you to a phenomenon all too well-known to all but the most gifted and talented computer scientists: the problem we hadn't thought of . (Empirical Modellers encounter these all the time.) It would not be fair for me to tell you what the problem is, because perhaps (like me) you hadn't thought of it. But in order to solve it, you will find it useful to think about the Sudoku model, and the definition of the string a1.

Further help for Exercise 1

It is probably a good idea to attempt this exercise by yourself initially, posting to the Forum or emailing if you have difficulty. A small set of definitions that you can consult if you are otherwise unable to make progress will be added later in an Appendix if required. You will have to be very gifted and talented to make use of the actual sample definitions supplied. If you find the exercise too easy, feel free to devise more complicated variants! If you should wish to move on to Exercises 2 and 3 and come back to Exercise 1 where you left off, this may well be possible, depending on how radically wrong your answer to Exercise 1 might be. And because of the open nature of the Empirical Modelling environment, for that we have no means of making provision. To begin afresh, you can always restart the workshop by refreshing the webpage.

Exercises in converting between coordinate systems

A standard problem in computer science is converting data from one representation and another. In the exercises 2 and 3, you have to devise definitions to translate from one coordinate system that can be used to reference the squares of the Sudoku grid to another.

The row-col and region coordinates for the Sudoku grid

Every cell of the Sudoku grid can be identified by its row and colum. For instance, the cell D9 has row-col coordinates (9,4). It can also be identified as the cell in the region 8 that is the 7th cell when you list the cells of that region in "reading order". For this reason, we shall ascribe the region coordinates (8,7) to D9.

Exercise 2: Devise Eden definitions to convert from row-col to region coordinates.

To start Exercise 2, click the middle button from the button menu. The 9 by 9 blank Sudoku grid will be displayed with two cells highlighted. The coordinates of the cell with a green background are determined by the Eden integer observables ixrow and ixcol, the row-col coordinates of the cell. If you click on a cell, the values of ixrow and ixcol will be updated appropriately. (You can confirm this using queries such as ?ixrow; etc.) The coordinates of the cell with a red border are determined by the Eden integer observables ixregion and regionix, the region coordinates of the cell. They initially have explicit values that you can change through the input. Your task is to define the Eden observables ixregion and regionix in terms of ixrow and ixcol so that wherever you move the green cell it always has a red border.

Exercise 3: Devise Eden definitions to convert from region to row-col coordinates.

To start Exercise 3, click the bottom button from the button menu. The 9 by 9 blank Sudoku grid will be displayed with two cells highlighted. The coordinates of the cell with a red border are determined by the Eden integer observables ixregion and regionix, the region coordinates of the cell. If you click on a cell, the values of ixregion and regionix will be updated appropriately. (You can confirm this using queries such as ?ixregion; etc.) The coordinates of the cell with a green background are determined by the Eden integer observables ixrow and ixcol, the row-col coordinates of the cell. They initially have explicit values that you can change through the input. Your task is to define the Eden observables ixrow and ixcol in terms of ixregion and regionix so that wherever you move the cell with a red border it always has a green background.

Further guidance for Exercises 2 and 3

Note that in both exercises two of the four observables ixrow, ixcol, ixregion and regionix have already been defined, and you only need to find a definition for the other two. In Exercise 2, for instance, you need to focus on how you calculate the index of the region and the index of the cell within the region from knowledge of the row and column in which it appears. It is possible to devise formulae (of the general - otherwise known as comical - form:

ixregion is (ixrow%19+(ixcol/17)*17)%31;

etc) that use only the operators integer division (/) and remainder (%).

Answers to Exercises 2 and 3

The answers to these exercises are implicit in the model itself, and if you think about it you can easily cheat (how?). If you find these exercises easy, consider how the models that are being used to support exercises 2 and 3 represent such things as: which cells on the grid should be highlighted, how you (as the pupil) currently suppose that row-col and region coordinates are related, how the row-col and region coordinates of the highlighted cells should be related, the way that the grid display responds to a mouse click, how the coordinates of the highlighted cells are related to the location of the mouse click etc. You can access all the relevant observables and definitions by queries through the interface. If you have appropriate technical knowledge of list and integer, string and character types you may find it helpful to realise that clicking on the cell F3 sets the observable currentsquare to the value ["F"," 3"]. And by the way, I'm also cheating (how?).

Footnote on comical form

Comical form is a technical term well-known to all amateur cricketers. It has been known to affect professional cricketers also, especially in some parts of Wales.